知识卡片
值对象要表达概念整体
值对象应把共同表达一个含义的属性组成整体,并提供与该含义相关的功能。原书图5.6把街道、城市、州从 Customer 的零散字段移入 Address,使“地址”成为可独立传递、理解的描述,而 Customer 仍保有自己的身份。值对象可以由其他值对象组成,也可引用实体;是否含引用不决定它自身有没有概念身份。参见[[值对象按描述而非身份理解]]。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第05章|Is "Address" a V ALUE O BJECT ? Who's Asking? · 查看原书依据
For example, street, city, and postal code shouldn't be separate attributes of a Person object. They are part of a single, whole address, which makes a simpler Person, and a more coherent VALUE OBJECT.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第38章《原书第05章|Is "Address" a V ALUE O BJECT ? Who's Asking?》(源文件:_epub-src/0321125215_ch05lev1sec3_split_001.html;图5.6:05fig06.gif)
- 结论依据:原文要求值对象的属性构成概念整体,用地址字段从 Customer 提出到 Address 的图示说明;另指出值对象可组合其他对象甚至引用实体。
- 原始内容:The attributes that make up a VALUE OBJECT should form a conceptual whole. ... For example, street, city, and postal code shouldn't be separate attributes of a Person object. They are part of a single, whole address, which makes a simpler Person, and a more coherent VALUE OBJECT .