← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 1971.o.1.b.4.e.3.a

创建事件还须维护历史回指

理解等级:中级

在原书当前货运模型中,事件指向 Cargo,Cargo 的 Delivery History 又保存事件集合。新建 Handling Event 后,若未在同一事务将它加入历史,两个方向会不一致;图7.5甚至提示更新 Cargo/History 可能发生争用。工厂可封装回指维护,但作者随即准备重构以消除这段别扭协作。这里记录的是原书当前设计的问题,不把增加双向同步视为最终方案。参见[[循环关联的实现取决于查询频率]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 原书第07章|Object Creation · 查看原书依据

      The Delivery History holds a collection of Handling Events relevant to its Cargo, and the new object must be added to this collection as part of the transaction. If this back-pointer were not created, the objects would be inconsistent.

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第56章《原书第07章|Object Creation》(源文件:_epub-src/0321125215_ch07lev1sec8.html;图7.5) - 结论依据:原文要求创建事件时把新对象加入 Delivery History 集合,否则关联不一致;图7.5展示跨 Cargo/History 的同步与事务争用。 - 原始内容:The Delivery History holds a collection of Handling Events relevant to its Cargo , and the new object must be added to this collection as part of the transaction. If this back-pointer were not created, the objects would be inconsistent. ... now we'll look at an alternative design that eliminates this awkward interaction altogether.