Domain-Driven Design
Domain-Driven Design
Eric Evans => 2003 book, pale blue, 550 pgs; 2014 thin orange book, 75 pages
Entity: identity first; Value Object: values first; Aggregate: consistency first; Domain Event: something happened; Repo: store/load domain objects; Domain Service: logic or behavior without a natural home; Factory: controlled creation; Bounded Context: meaning by boundary.
Entity
= Has
unique
id. Its state can change, but it remains the same
thing.
Characteristics: unique identity, mutable state, identity over attributes, life cycle.
Ex: Customer ID 1024 is the same person even if their name or address changes.
Value Object = Small, immutable object defined by its attributes. 2 equal if values are equal.
Characteristics: no identity, immutable, structural equality, descriptive or quantifying meaning.
Ex: A $50 cash note is as any other $50 cash note. Ex2: address like “123 Main St, Plano, TX.”
Aggregate = Group of internal related objects treated as one unit for consistency.
Characteristics: Consist boundary, related objects, one trans unit, controlled access through root.
Ex: Agg. Root of Order holds the internal Line Items Agg. and Pricing Details Agg.
Aggregate Root = Gate Keeper. Conceptual. Protects truths (invariants such as sum or IsValid).
Characteristics: single access point, controls invariants, owns internal objects, enforces consistency.
Ex: Order is the Agg. Root.
Domain Event = State Changed in past. Notifies other parts that a change occurred.
Characteristics: Past-tense event, business significance, decoupled comm, event-driven reaction.
Ex: “Order Placed,” “Payment Received,” or “Item Shipped.”
Repo = Gets and saves domain objects.
Characteristics: persistence abstraction, collection, hides storage details, works with aggregates.
Ex: A CustRepo can get, update, and insert customers without domain knowing SQL.
Domain Service = Miscellaneous bucket for large or behavior objects.
Characteristics: stateless behavior, domain logic, crosses object boundaries, no natural owner.
Ex: A currency exchange service that calculates conversion across different accounts.
Factory = Creates multiple or complex (rule or long steps) objects with valid starting state.
Characteristics: controlled creation, valid initialization, encapsulates build logic, hides complexity.
Ex: A factory builds a new Order with a default status, a unique number, and required line items.
Bounded Context = Clear model and language boundary. Same word can different meanings.
Characteristics: explicit boundary, model consistency, context-specific meaning, protects clarity.
Ex: “Customer” could mean billing account holder; in another, a shipping recipient.
Characteristics: unique identity, mutable state, identity over attributes, life cycle.
Ex: Customer ID 1024 is the same person even if their name or address changes.
Value Object = Small, immutable object defined by its attributes. 2 equal if values are equal.
Characteristics: no identity, immutable, structural equality, descriptive or quantifying meaning.
Ex: A $50 cash note is as any other $50 cash note. Ex2: address like “123 Main St, Plano, TX.”
Aggregate = Group of internal related objects treated as one unit for consistency.
Characteristics: Consist boundary, related objects, one trans unit, controlled access through root.
Ex: Agg. Root of Order holds the internal Line Items Agg. and Pricing Details Agg.
Aggregate Root = Gate Keeper. Conceptual. Protects truths (invariants such as sum or IsValid).
Characteristics: single access point, controls invariants, owns internal objects, enforces consistency.
Ex: Order is the Agg. Root.
Domain Event = State Changed in past. Notifies other parts that a change occurred.
Characteristics: Past-tense event, business significance, decoupled comm, event-driven reaction.
Ex: “Order Placed,” “Payment Received,” or “Item Shipped.”
Repo = Gets and saves domain objects.
Characteristics: persistence abstraction, collection, hides storage details, works with aggregates.
Ex: A CustRepo can get, update, and insert customers without domain knowing SQL.
Domain Service = Miscellaneous bucket for large or behavior objects.
Characteristics: stateless behavior, domain logic, crosses object boundaries, no natural owner.
Ex: A currency exchange service that calculates conversion across different accounts.
Factory = Creates multiple or complex (rule or long steps) objects with valid starting state.
Characteristics: controlled creation, valid initialization, encapsulates build logic, hides complexity.
Ex: A factory builds a new Order with a default status, a unique number, and required line items.
Bounded Context = Clear model and language boundary. Same word can different meanings.
Characteristics: explicit boundary, model consistency, context-specific meaning, protects clarity.
Ex: “Customer” could mean billing account holder; in another, a shipping recipient.
Comments
Post a Comment