Values types that measure, quantify, or describe things are easier to create, test, use, optimize, and maintain. Domain model 中真正的 Value Objects 并不是业务领域中的一种物品 (thing),它是用于测量、量化或是描述物品的。例如,一个人的年龄,它并不是一件事物,而是用来量化这个人从出生到现在的年数。 如果设计正确,Value Objects 的实例在创建之后就可以被随意传递,开发者可以即刻忘记这类对象,无论它们的生命周期是长是短,更无需担心对象的值是否被修改。在解决 Ubiquitious Language 的时候,确定正在建模的 domain concept 是否适合 Value Objects 是第一要务。有这么几个标准可以用来辅助判断: + It measures, quantifies, or describes a thing in the domain. + It can be maintained as immutable. + It models a conceptual whole by composing related attributes as an integral unit. + It is completely replaceable when the measurement or description changes. + It can be compared with others using Value equality. + It supplies its collaborators with Side-Effect-Free Behavior. 在绝大多少情况下,Value Objects 都是 immutable 的,一旦它们被创建出来,就无法再修改它的值。在 Java 或是 C# 这样的语言中,开发者往往使用 constructor 来构造 Value Objects 的实例,传入的参数被用于确定该对象的全部状态。构造参数可能直接被保存为 Value Objects 的 attributes,也可能被用于推导 (derive) 出对象内的一个或是若干 attributes...