Domain Driven Design Entity Vs Value Object
Inline value objects fields in the entity table a simple design that also supports refactoring of value objects from an entity.
Domain driven design entity vs value object. Entities when two objects are deemed equal on the basis of their identity they are considered entities. I know the topic isn t new and there are a lot of articles on the internet discussing it already. That is unlike an entity which has a unique identifier and remains distinct even if its properties are otherwise identical two value objects with the exact same properties can be considered equal.
Suppose you have two employee objects in your system i e. The topic described in this article is a part of my domain driven design in practice pluralsight course. So treat po as an aggregate of the po entiity and the line item value objects.
An entity object on the other hand has its own life and rich behavior regardless of the data it contains. A value object is fully identified by a combination of values it contains. I wrote about entities and value objects some time ago.
The difference between entities and value objects is an important concept in domain driven design. A value object represents an aspect. Value objects are a pattern first described in evans domain driven design book and further explained in smith and lerman s domain driven design fundamentals course.
And make the po entity the root of the aggregate. Using a table for each type of value object a design that allows. In this post i d like to talk about differences between entity vs value object in more detail.
A value object class represents an entity in the domain that mostly contains data and lives for the data it contains. Entity objects are usually objects with a longer lifetime. So what we have in this example is an aggregate consisting of a single entity the purchase order functioning as the root of the aggregate and a set of one or more associated line item value objects.