返回主题:资源库与查询

此卡片不在当前主题的阅读序列中,可返回主题继续阅读。

知识卡片

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

全局查询只开放必要聚合根

理解等级:中级

仓储的直接查询入口只给确实需要全局访问、又不便从其他对象遍历到的聚合根。临时对象无需查询;聚合内部对象必须从根遍历。值对象通常也随所属实体取得,按属性找同值对象往往等同于重新创建;原书保留已保存行程和有限枚举值等例外。若必须反复搜索某个“值”的既有实例,应重新检查它是否其实有未识别的实体身份。参见[[聚合根限定外部引用]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第46章《原书第06章|Repositories》(源文件:_epub-src/0321125215_ch06lev1sec3.html;小节 Repositories) - 结论依据:原文先排除临时对象、易遍历对象和聚合内部对象,再限定需要全局查询的聚合根,并讨论值对象例外及潜在身份误判。 - 原始内容:any object internal to an AGGREGATE is prohibited from access except by traversal from the root . ... Provide REPOSITORIES only for AGGREGATE roots that actually need direct access. Keep the client focused on the model, delegating all object storage and access to the REPOSITORIES .