知识卡片
实体与值对象工厂输入不同
不可变值对象创建后就是最终状态,工厂需要取得完整属性。实体工厂先取得形成有效聚合的必要属性;不影响不变量的细节可稍后补充,还需处理身份:外部指定的标识须作为输入,程序分配时工厂可协调取号和赋值,实际唯一号可能来自数据库序列等基础设施。值对象没有实体身份分配问题。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第06章|Factories · 查看原书依据
VALUE OBJECTS are Immutable; the product comes out complete in its final form. So the FACTORY operations have to allow for a full description of the product. ENTITY FACTORIES tend to take just the essential attributes required to make a valid AGGREGATE.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第45章《原书第06章|Factories》(源文件:_epub-src/0321125215_ch06lev1sec2.html;小节 Entity Factories Versus Value Object Factories)
- 结论依据:原文按是否不可变、是否需身份区分两类工厂;实体只需初始有效聚合,程序取号可由基础设施实施、工厂协调使用。
- 原始内容:V ALUE OBJECTS are Immutable; the product comes out complete in its final form. So the FACTORY operations have to allow for a full description of the product. E NTITY FACTORIES tend to take just the essential attributes required to make a valid AGGREGATE .