- Slides: 7
DOMAIN DRIVEN DESIGN Dave 12 May 2015
WHAT IS DDD? Set of principles to aid in building complex systems Enables us to focus on core problem domain NOT an architecture standard or design pattern
DOMAIN MODEL Fluently describes the domain, rules, requirements and intentions Must always be consistent and rich Free from infrastructural concerns (DB, UI, networking, host, frameworks) Aggregates, entities, value objects and domain events
ENTITIES A real thing in our domain which is not defined by its properties but rather by its identity. DO create as an entity if something is uniquely identifiable (litmus test) DO perform invariant validation & enforce consistently DO NOT use property bags (they are promiscuous) DO NOT design entities from database tables or API models
VALUE OBJECTS A real thing in our domain which is identified by the value of its properties and not by some identity attribute. DO create value objects as immutable DO NOT represent complex things with just value types
AGGREGATES A cluster of associated objects that we treat as a unit for the purpose of data consistency, integrity and invariant preservation. Draws consistency boundary around related entities and value objects. All external access to the aggregate is done through the aggregate root. Reference an aggregate by the root’s identity. External entities can hold references to any aggregate root, but never to any other entity or value object within the aggregate. To access any other part of the aggregate, you must navigate from the aggregate root.
REPOSITORIES Mediates between the domain and persistence layers for retrieving, adding and updating aggregates. One repository, one aggregate Repository implementation is not relevant to the domain