문제

I am currently reading "Implementing Domain Driven Design" book and on one of the pages shows

public class ProductBacklogItemService ... {
    ...
    @Transactional
    public void planProductBacklogItem(
        String aTenantId, String aProductId,
        String aSummary, String aCategory,
        String aBacklogItemType, String aStoryPoints) {

        Product product =
            productRepository.productOfId(
                    new TenantId(aTenantId),
                    new ProductId(aProductId));

        BacklogItem plannedBacklogItem =
            product.planBacklogItem(
                    aSummary,
                    aCategory,
                    BacklogItemType.valueOf(aBacklogItemType),
                    StoryPoints.valueOf(aStoryPoints));

        backlogItemRepository.add(plannedBacklogItem);
    }
    ...
}

His book also says Reference: In DDD the Aggregate should represent the transactional boundary. A transaction that requires the involvement of more than one aggregate is often a sign that either the model should be refined, or the transactional requirements should be reviewed, or both.

In the above example, wouldn't Product and BacklogItem be 2 different aggregates in a single transaction? I am confused. Can anyone share some thoughts?

도움이 되었습니까?

해결책

I think that 'the involvement of' in this case may mean 'changes to' and since Product is not modified only one AR is affected. I actually read this bit last night and just a bit further on he does mention that one should really aim to only manipulate one AR per transaction. So it seems as though there will be exceptions.

It isn't a bad idea to only manipulate a single AR per transaction and typically you'll find that you end up with such a design anyway.

There are always going to be exceptions to the rule but those should be carefully considered.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top