开发者

DDD Aggregate Design Question

Here is an oversimplified version of what I am trying to do.

I have a Story that gets reviewed by a user and that user can add it to their ballot. The business rule is a story can ONLY belong to the reviewers ballot and the ballot cannot contain more than 12 stories.

Right now I have the Story as the agg开发者_如何学运维regate root which contains lots of behavior and state transitions. Until now, the reviewer has not come into the picture. I'm having a hard time modeling this design. Do I have two aggreates now Story and StoryReviewer?

Any ideas would be great!


If I understand you correctly Story can be in 'unreviewed' state, in other words the Story exists by itself and then, maybe, gets reviewed and added to user ballot. If this is true, then it looks like you have two aggregate roots User and Story.

If its not true and story always belongs to some user's ballot and can never be reassigned from one User to another User than you may only need one aggregate root: User. And Story is just an entity within User aggregate.

Either way the ballot itself is probably an entity within User/StoryReviewer aggregate. Ballot seems like a good place to enforce the 12-stories-per-ballot rule.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜