← 返回起始笔记位置

知识卡片

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

交付历史可按货物身份临时重建

理解等级:中级

原书重构后,Delivery History 不再持久保存事件集合,因此可在需要回答货物状态问题时临时生成。每次生成的是新对象,但始终关联同一 Cargo,业务身份仍沿着货物身份延续。Cargo 工厂也不必在新建货物时附带空历史。这里的“可重建”依赖历史本身没有其他持久状态;若后来承载独立状态,需重审这一设计。参见[[交付历史借用货物身份]]。

这张卡片看不懂?

已有反馈 · 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) - 结论依据:原文说历史失去持久状态后可按需推导,反复重建的实体仍靠关联同一货物保持连续性,货物工厂可简化。 - 原始内容:This leaves the Delivery History with no persistent state. At this point, there is no real need to keep it around. We could derive Delivery History itself whenever it is needed to answer some question. 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.