← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 765.f.1

值对象以值相等

理解等级:中级

值对象由属性值的组合确定身份:RGB完全相同就是同一种颜色,无需ColorId。改变任一属性得到的是新值,因此值对象应不可变,修改操作返回新实例,相等判断比较值而非引用或数据库ID。适合描述实体属性,也可表达金额、单位或状态。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 应对复杂业务逻辑 · 查看原书依据

      A value object is an object that can be identified by the composition of its values. For example, consider a color object: class Color { int _red; int _green; int _blue; } The composition of the values of the three fields red, green, and blue defines a color. Changing the value of one of the

    参考来源

    - 位置:《Learning Domain-Driven Design》第6章《应对复杂业务逻辑》(来源项目:book-sources;源文件:extracted/Learning Domain-Driven Design/_epub-src/OEBPS/ch06.html) - 结论依据:原文围绕本卡所述机制给出定义、适用条件及相关取舍,以下摘录为直接依据。 - 原始内容:A value object is an object that can be identified by the composition of its values. For example, consider a color object: class Color { int _red; int _green; int _blue; } The composition of the values of the three fields red, green, and blue defines a color. Changing the value of one of the