Aggregates

Learn what aggregates are and their importance in the Domain Driven Design world.

When dealing with complex bounded context, perhaps it is necessary to create a huge number of entities and value objects, perhaps it is necessary to create interactions between them, and perhaps this situation may lead to creating a big ball of mud. As explained before, this is an anti-pattern where interactions among objects are unmanageable. It can be described as spaghetti code.

A big ball of mud implementation tends to grow out of control and obviously, it is difficult to maintain over time. Domain Driven Design understands this problem and solves it by defining a tactical pattern called Aggregate.

What is an aggregate?

An aggregate object is a cluster of entities and value objects that are treated as a single unit from the domain and data perspective. This object acts as a load balancer in terms of accessing a set of nodes. What it means is that an aggregate is the only access point for external objects. As the image below shows, an aggregate has clear bounds, and artifacts inside have no contact with the outside world:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy