Domain-Driven Design - Entities

In Domain-Driven Design an Entity is an object that represents an object with identity, for example, a person, a product, or an enterprise.

Characteristics

  • Entities have an identity:
    • Identity is immutable.
    • Identity is globally unique.
    • Identity is intangible (Does not exist in the real world, because real world identifiers can change).
  • Entities can have Value Objects as properties.
  • Entity’s properties should be edited only within it and do not expose reading and writing to any.
  • Entities do not include metadata properties (Created on, created by, updated on, delete on, etc.) unless it is part of the business model.
  • Entities can have a private constructor to prevent creating new instances from a public constructor.
  • Entities can include a Static Factory Method pattern to return new entity instances.

Examples