在DDD中,价值对象的实际优势是什么? [英] In DDD, what are the actual advantages of value objects?

查看:78
本文介绍了在DDD中,价值对象的实际优势是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我了解到实体对象有一个ID,而值对象没有,但是在最常见的示例中,您的人员实体具有一个附加了地址值对象的对象.创建单独的地址对象而不是仅将地址属性保留在Person Entity中的最大优点是什么?

I have gotten so far that I understand entity objects have an ID while value object have not, but in the most common example you have the person entity that have a address value object attached to it. What is the big advantage of creating a separate address object instead of just keeping the address properties within the Person Entity?

推荐答案

除了已经提到的内容外,

In addition to the things already mentioned, Greg Young makes a big deal out of the fact that since they are immutable, you can validate them on creation and never worry about validation again. If the state cannot be changed, then you know it's always valid.

这篇关于在DDD中,价值对象的实际优势是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆