开发者

A series of simple Aggregate Root questions (Domain Driven Design)

I have a few (hopefully) simple questions about aggregate roots in domain driven design:

  1. Is it okay to have an aggregate 开发者_StackOverflow中文版root as a property of another aggregate root?
  2. Is it okay to have a given entity inside two or more aggregate roots?

My final question is a bit more involved. I have a website that has a few entities that really belong to a "website" aggregate root. They are 'News', 'Products', and 'Users'. There isn't a 'Website' table in the database, but a 'Website' seems like a good aggregate root for these three entities. How is this usually achieved?

Thanks!


Do you have any consistency rules spanning the whole website (concerning multiple news products and usesrs)? If not, these entities (news, products, users) are good candidates for being you aggregate roots.

Aggregate root main function is to provide consistency and transaction semantics boundary.

To answer you questions:

  1. Yes, it is ok as long as this referred aggregate root is not modified during any operation of the containing AR. This is connected to the consistency boundaries: operations spanning multiple aggregates are not guarantied to produce consistent results so they should be avoided

  2. No, an entity (which is not AR) can be a part of only one aggregate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜