知识卡片
重建实体须保留原身份
从数据库记录或 XML 等传输表示重建既有实体时,工厂须接收并保留原标识;另发新标识会切断实体的连续性。若存储内容违反不变量,不能把既存事实当作新建请求直接忽略,也不能返回违规对象,需要明确修复策略。图6.16–6.17分别展示关系数据库映射和 XML 解析的原书示例;仓储负责存取入口,重建工厂封装对象装配。参见[[对象生命周期由三类模式协作]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第06章|Factories · 查看原书依据
There has to be some strategy for repairing such inconsistencies, which can make reconstitution more challenging than the creation of new objects.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第45章《原书第06章|Factories》(源文件:_epub-src/0321125215_ch06lev1sec2.html;图6.16–6.17)
- 结论依据:原文明确重建实体不分配新追踪 ID,识别属性作为工厂输入;既存违规对象须有修复策略,并以关系记录及 XML 图例说明重建复杂度。
- 原始内容:An ENTITY FACTORY used for reconstitution does not assign a new tracking ID . ... To do so would lose the continuity with the object's previous incarnation. ... There has to be some strategy for repairing such inconsistencies, which can make reconstitution more challenging than the creation of new objects.