DDD 聚合设计问题

发布于 2024-11-30 00:38:08 字数 216 浏览 0 评论 0原文

这是我正在尝试做的事情的过于简化的版本。

我有一个故事由用户审核,该用户可以将其添加到他们的选票中。业务规则是一个故事只能属于审阅者选票,并且选票不能包含超过 12 个故事。

现在我将故事作为聚合根,其中包含许多行为和状态转换。到目前为止,审稿人还没有介入。我很难对这个设计进行建模。我现在有两个聚合 Story 和 StoryReviewer 吗?

任何想法都会很棒!

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 aggregate 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

漆黑的白昼 2024-12-07 00:38:08

如果我理解正确的话,故事可以处于“未经审查”状态,换句话说,故事本身存在,然后也许会被审查并添加到用户选票中。如果这是真的,那么看起来您有两个聚合根 User 和 Story。

如果事实并非如此,并且故事始终属于某个用户的选票,并且永远无法从一个用户重新分配给另一个用户,那么您可能只需要一个聚合根:User。 Story 只是 User 聚合中的一个实体。

无论哪种方式,选票本身可能是 User/StoryReviewer 聚合中的一个实体。 Ballot 似乎是执行每张选票 12 层楼规则的好地方。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文