Am I allowed to have “incomplete” aggregates in DDD?

前端 未结 5 618
再見小時候
再見小時候 2021-02-05 10:04

DDD states that you should only ever access entities through their aggregate root. So say for instance that you have an aggregate root X which potentially has a lot of

5条回答
  •  南方客
    南方客 (楼主)
    2021-02-05 10:52

    I consider an aggregate root with a lot of child entities to be a code smell, or a DDD smell if you will. :-) Generally I look at two options.

    1. Split your aggregate into many smaller aggregates. This means that my original design was not optimal and I need to identify some new entities.
    2. Split your domain into multiple bounded contexts. This means that there are specific sets of scenarios that use a common subset of the entities in the aggregate, while there are other sets of scenarios that use a different subset.

提交回复
热议问题