Value vs Entity objects (Domain Driven Design)

后端 未结 8 1056
眼角桃花
眼角桃花 2020-11-27 10:10

I have just started reading DDD. I am unable to completely grasp the concept of Entity vs Value objects.. Can someone please explain the problems (maintainability, performan

8条回答
  •  独厮守ぢ
    2020-11-27 10:22

    Any object that is collectively defined by all of it attributes is a value object. If any of the attributes change you have a new instance of a value object. This is why value objects are defined as immutable.

    If the object is not fully defined by all of its attributes then there are a subset of attributes that make up the identity of the object. The remaining attributes can change without redefining the object. This kind of object cannot be defined at immutable.

    A simpler way of making the distinction is to think of value objects as static data that will never change and entities as data that evolves in your application.

提交回复
热议问题