Domain Driven Design Value Object C
As someone who uses many domain driven design patterns in my net code i ve long wanted to have built in immutable value objects in c.
Domain driven design value object c. Value object implementation in c. Entity can be identified either by its ids or combination of some attributes. The term was coined by eric evans. When going for domain driven design these are the element of domain driven design.
An object that can be identified uniquely or by its identifier. Entity is an identity. Focus on the core domain and domain logic. Has no concept of an identity two different instances of a value object with the same values are considered equal.
If it has real meaning in the domain and helps to better translate the business by turning a dateofbirth into a value object then by all means go for it. In terms of implementation you can have a value object base class that has basic utility methods like equality based on the comparison between all the attributes since a value object must not be based on identity and other fundamental characteristics. You can t change their state. Because they re immutable once created.
A value object is an immutable type that is distinguishable only by the state of its properties. In his book domain driven design ddd eric evans encourages the use of value objects in domain models. If the primitive property is acting primarily as a data transfer object don t turn it into a value object. 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 value objects are a pattern first described in evans domain driven design book and further.
Two important building blocks when we talk about code are entities and value objects. In the domain driven design space a value object. In the end do what makes sense and keep the code simple and maintainable. Their state is fully set when they re created.
Check out his book on the subject. Collaboration between technical and domain experts. S arp architecture a pragmatic c example not as pure a ddd approach perhaps due to its lack of a real domain problem but still a nice clean approach. Some interpretations of domain driven design do advocate data modeling and i think this is what your question is about.
Value objects have a few characteristics.