知识卡片
处理事件因独立查询成为聚合根
货运案例中 Delivery History 只随所属 Cargo 被访问,且借货物身份,可放进 Cargo 聚合;Delivery Specification 是值对象,也可纳入。Handling Event 虽为某件货物产生,却还可能按 Carrier Movement 独立查询装载与准备操作,因此原书图7.3把它设为另一聚合根。边界取决于对象是否需脱离货物单独访问,而非只看“为谁创建”。当前首版尚无这项查询需求,是否提供仓储另作判断。参见[[聚合根限定外部引用]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第07章|Aggregate Boundaries · 查看原书依据
With no need for direct global access, and with an identity that is really just derived from the Cargo, the Delivery History fits nicely inside Cargo's boundary, and it does not need to be a root.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第53章《原书第07章|Aggregate Boundaries》(源文件:_epub-src/0321125215_ch07lev1sec5.html;图7.3)
- 结论依据:原文先把交付历史与规格纳入 Cargo 聚合,再因 Handling Event 可按 Carrier Movement 独立查询而将其设为自己的聚合根。
- 原始内容:With no need for direct global access, and with an identity that is really just derived from the Cargo , the Delivery History fits nicely inside Cargo's boundary, and it does not need to be a root. ... So the Handling Event should be the root of its own AGGREGATE .