Aggregates
An Aggregate is a cluster of domain objects that are treated as a single unit with regards to data changes.
The aggregate ensures that all the changes to the objects within the aggregate are performed in a consistent and transactional manner.
Key characteristics of an Aggregate are:
Consistency Boundary: The aggregate defines a clear boundary for transactional consistency. All invariants and business rules within an aggregate must be satisfied as a whole, ensuring that the domain remains in a valid state at all times.
Encapsulation: The internal structure and state of the aggregate's objects are hidden from the outside world. External entities can only interact with the aggregate through its root.
Lifecycle: Aggregates are typically long-lived, persisting over multiple transactions. They should be designed with consideration for their lifecycle management.
Isolation: Aggregates should not directly reference or hold references to other aggregates. Instead, they can reference other aggregates by their unique identifiers (IDs).
Eiffel.Modelling.Abstractions NuGet package contains base aggregate class. By using abstract Aggregate class you can define your aggregates.
Each Aggregate is likely to contain more than one function and these functions are business needs demanded by domain experts/stakeholders. Each function usually requires notifying other members of the system that an event has occurred. These events are called Domain Events. Each Aggregate is responsible for keeping the events occurring within itself. Each Aggregate must have a uniquely defined identity type and primary key type required for the database. You can find the identity details specific to the aggregates in the Business Identifiers section. Example Booking Aggregate with BookingCancelled domain event.
Last updated