In Domain-Driven Design (DDD), Entities are tracked by a unique ID that stays the same even if their properties change, whereas Value Objects have no ID and are defined completely by their attribute values. [1, 2, 3]
Entities
Unique Identity: Defined by a persistent identifier (like a primary key, user ID, or social security number).
Mutable: Their attributes and state can change over time while the object remains the same entity.
Lifecycle: They track a business lifecycle and history.
Value Objects
No Identity: They do not have a unique identifier. Two value objects with the exact same data are considered equal.
Immutable: They cannot be modified after creation. If a value needs to change, you replace it with a brand-new instance.
Interchangeable: If you swap one value object for another with identical values, the business model treats them as the exact same thing.
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime