开发者

Identifying the aggregate roots

开发者 https://www.devze.com 2023-02-15 15:55 出处:网络
http://i51.tinypic.com/2ueqidt.jpg Let us assume the following relationships (diagram).A FundCompany has Funds, and Accounts.There is also a FundAccount which creates a many-to-many relationship (as

http://i51.tinypic.com/2ueqidt.jpg

Let us assume the following relationships (diagram). A FundCompany has Funds, and Accounts. There is also a FundAccount which creates a many-to-many relationship (as well as other attributes at the relationship level) between Accounts and Funds. Lastly an Account has one or more Beneficiary.

The FundCompany is an aggregate root as it’s at the top of the pyramid. Neither Account nor Fund can exist without the FundCompany. FundAccount cannot exist without both Fund and Account; does that make them both aggregate roots? Or is Fund still the only aggregate root, having to go through it to perform operations on FundAccount entities? The fact that the Account also has Beneficiaries, which cannot exist without the Account, does that also signal Account being an aggregate root?

All of the entities on this diagram will require CRUD operations and screens in my application. The reason I’m bringing this is up is most often every UI screen will store the ID of the row/entity it’s referencing. So for example a user clicks “Details” on a table with Funds, I might need to retrieve a fund via its ID. My understanding is that if an entity needs direct access then it’s an aggregate root in itself. However this would make a lot of 开发者_StackOverflowentities aggregate roots by default.

Based on the answers to above questions I have to map these operations to the proper aggregate root’s repository.


Whole your diagram is single aggregate = it have single aggregate root - the top level FundFamily. If Fund and Account can't live without FundFamily their can't be aggregate roots.

0

精彩评论

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