← 返回起始笔记位置

知识卡片

普通读书笔记卡 · 1971.o.1.b.4.d.1.c.4.a.7

模型边界允许替换关联实现

理解等级:中级

原书把 Delivery History 的事件集合换成仓储查询,仍保留 Cargo、Handling Event 等领域概念及身份关系。变化收束在 Cargo 聚合内部,并新增事件仓储;Handling Event 无须重做领域设计,具体持久化实现可能调整。这个案例说明:实体、值对象和聚合边界清楚时,可根据新发现改变关联的实现,而不必重画整个领域模型。这里是原书设计示例,不能保证任何变更都只影响聚合内部。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第57章《原书第07章|Pause for Refactoring: An Alternative Design of the Cargo Aggregate》(源文件:_epub-src/0321125215_ch07lev1sec9.html) - 结论依据:原文称两种设计处于同一模型内,当前变化封装于 Cargo 聚合边界,新增事件仓储而未重设计事件本身。 - 原始内容(关联与身份):Replacing the Delivery History's collection of Handling Events with a query would allow Handling Events to be added without raising any integrity issues outside its own AGGREGATE . [...] To take responsibility for the queries, we'll add a REPOSITORY for Handling Events . [...] We can derive this object because, although the ENTITY will be repeatedly recreated, the association with the same Cargo object maintains the thread of continuity between incarnations. (`[...]` 略去中间设计条件和查询细节;术语前后的空格沿用原 EPUB 标签抽取形式。) - 原始内容(变更边界):But the important point is that these are degrees of freedom within the same model. By modeling VALUES , ENTITIES , and their AGGREGATES as we have, we have reduced the impact of such design changes. For example, in this case all changes are encapsulated within the Cargo's AGGREGATE boundary. It also required the addition of the Handling Event Repository , but it did not call for any redesign of the Handling Event itself (although some implementation changes might be involved, depending on the details of the REPOSITORY framework). (术语前后的空格沿用原 EPUB 标签抽取形式。)