Aggregates are Blackboxes


Last Updated on Oct 06, 2022

Over the last 3 decades, businesses in most domains have migrated a part, or all, of their business processes into software.

In DDD, business processes of the actual world manifest as Aggregates in code.

Aggregates represent distinct concepts in the business and encapsulate all aspects of that business process. This includes the data, events, and workflows associated with a process in their entirety.

Aggregates prevent the leakage of concepts into the rest of the domain and are entirely responsible for processing aspects related to a concept. Put another way, you can clearly identify where a process in the real world is mapped in code if you know the aggregate responsible for the workflow.

All domain elements, business rules, and events related to a concept are accessible only through the aggregate.

You can say that an aggregate encapsulates a domain concept, exposing just enough for the rest of the ecosystem to communicate with it. The exposure being talked about here is typically in the form of public APIs, that are usually both forward and backward compatible.

The linkages between domain elements enclosed within Aggregates are only known to the aggregate and are not exposed to the outer world. If an external party could traverse (or even understand) the information graph enclosed within an aggregate, then they would no longer be loosely coupled. Any structural change within the aggregate would cause ripple effects across the bounded context.

So aggregates serve best when they behave as blackboxes to the rest of the ecosystem.


© 2022 Ambitious Systems. All Rights Reserved.