Value vs Entity objects (Domain Driven Design)

后端 未结 8 1060
眼角桃花
眼角桃花 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:28

    In a very simple sentence I can say, we have three types of equality:

    • Identifier equality: a class has id filed and two objects are compared with their id field value.
    • Reference equality: if a reference to two objects has a same address in memory.
    • Structural equality: two objects are equal if all members of them are matched.

    Identifier equality refers only to Entity and structural equality refers to Value Object only. In fact Value Objects do not have id and we can use them interchangeably. also value objects must be immutable and entities can be mutable and value objects will not have nay table in database.

提交回复
热议问题