知识卡片
仓储找旧对象工厂造新对象
工厂负责新对象的创建与复杂装配;仓储负责查找既有对象及其存取。仓储取回记录时可委托工厂重建实例,但概念上仍是原实体,身份不变;新对象则由客户端经工厂创建后加入仓储。原书图6.22–6.23展示这两条路径。技术上重建也会实例化对象,职责上仍应区分“新建”和“找回”。参见[[重建实体须保留原身份]]。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第06章|Repositories · 查看原书依据
These two views can be reconciled by making the REPOSITORY delegate object creation to a FACTORY, which (in theory, though seldom in practice) could also be used to create objects from scratch.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第46章《原书第06章|Repositories》(源文件:_epub-src/0321125215_ch06lev1sec3.html;图6.22–6.23)
- 结论依据:原文区分新对象创建与旧对象查找,允许仓储委托工厂重建,并用两图分别展示查旧对象和新对象存储路径。
- 原始内容:The FACTORY makes new objects; the REPOSITORY finds old objects. The client of a REPOSITORY should be given the illusion that the objects are in memory. ... These two views can be reconciled by making the REPOSITORY delegate object creation to a FACTORY , which (in theory, though seldom in practice) could also be used to create objects from scratch.