O'Reilly logo

Implementing Domain-Driven Design by Vaughn Vernon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making Aggregates Work Together through Identity References

Prefer references to external Aggregates only by their globally unique identity, not by holding a direct object reference (or “pointer”). This is exemplified in Figure 10.6.

Image

Figure 10.6. The BacklogItem Aggregate, inferring associations outside its boundary with identities

We would refactor the source to

public class BacklogItem extends ConcurrencySafeEntity  {     ...     private ProductId productId;     ... }

Aggregates with inferred object references are thus automatically smaller because references are never eagerly loaded. The model can perform better ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required