← 返回刚才阅读的位置

知识卡片

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

聚合根限定外部引用

理解等级:中级

聚合是为数据变更而当作一个单位的一组相关对象,具有边界和唯一的根实体。边界外的对象只能长期引用根,不能保存内部成员的引用;根可临时交出内部实体供单次操作使用,也可交出值对象的副本。数据库直接查询也应只取得根,再沿关联访问内部成员。这使外部变更必须经根进入,避免根在不知道的情况下被改坏。参见[[对象生命周期由三类模式协作]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第44章《原书第06章|Aggregates》(源文件:_epub-src/0321125215_ch06lev1sec1.html;图6.2) - 结论依据:原文定义聚合、根和边界,并逐条规定外部引用、临时内部引用、值副本及数据库查询路径;图6.2展示对轮胎的外部引用被禁止。 - 原始内容:An AGGREGATE is a cluster of associated objects that we treat as a unit for the purpose of data changes. Each AGGREGATE has a root and a boundary. ... Nothing outside the AGGREGATE boundary can hold a reference to anything inside, except to the root ENTITY . ... As a corollary to the previous rule, only AGGREGATE roots can be obtained directly with database queries.