Skip to content

Aggregates, value objects and enums

The model inside a bounded context: aggregates with their properties, invariants, domain events, entities and methods; value objects; enums.

Aggregates

An aggregate is a consistency boundary: what must be true together after every change. It belongs to one bounded context and holds:

PartWhat it holds
PropertiesEach with a name and a type.
InvariantsThe rules that always hold, such as "An order has at least one line item".
Domain eventsThe events it raises, each with a summary and a payload.
EntitiesEntities inside it, with their own properties and invariants.
MethodsInputs, steps, and outcomes that succeed or fail with a message, a return type or a raised event.

Value objects

A value object is a value without identity, such as Money or Address. It has properties, invariants and methods, but no domain events or entities.

Enums

An enum lists named cases with a description each, such as PaymentMethod with the cases card, invoice and voucher.

Types

A property, input or return type is one of:

  • a primitive: text, number, bool, date or id;
  • a reference to another artefact: an aggregate, value object, enum, data contract or read model;
  • a collection of those: list, set or map.

Any type may be nullable. A reference is stored by id, so renames never break it.

Lists and order

Properties, invariants, events, entities, methods, cases, steps and outcomes keep the order you give them; drag to reorder. Archiving a member, such as a property or a case, keeps it in the history.

Next steps