Aggregates are Modeled Processes


Last Updated on Oct 04, 2022

A Domain Model has different representations suited for distinct purposes:

  • The model in the Real World is a collection of business processes and users interacting with the business in the real world.
  • The model in Mind is an understanding of the business processes expressed succinctly to capture on paper or verbally. Consider this as a map that showcases the natural terrain. A map is not accurate, nor does it need to be. It is just a representation of the landscape suited for a specific purpose.
  • The model in Code is a programmatic translation of the model in mind, represented as code and data objects. This model is where traditionally, most translation happens and where most information is lost. Programming paradigms can force the developer to create a completely disconnected technical model from the business model, thus necessitating a translation layer for business users to understand the model in code.
  • The model in Memory closes the loop with reality, with an instance of the codebase running in a computational environment somewhere on the internet.

As can be seen, a business process needs to be mapped (somehow) to a piece of code running in memory. In DDD, business processes are typically modeled in code as Aggregates, which act as data and logic containers.

Each process maps to one or more Aggregates, which work together to serve the business process. All aspects of a business process - data, events, workflows - are enclosed within the Aggregate cohesively. Aggregates are responsible for ensuring that all invariants within them are satisfied, as they hold all parts of the business process.

From a business user's perspective, aggregates are akin to blackboxes. Because they encapsulate all business logic, domain logic related to a business process is colocated in code without leaking to other application parts.

Also, since all processes in the real world are state modifications in some way (Entities transforming from one state to another), one can consider aggregates as state machines that step through each part of the business process while representing the current state clearly.


© 2022 Ambitious Systems. All Rights Reserved.