19 Aggregates

WHAT’S IN THIS CHAPTER?

  • How to deal with complex entity and value object relationships
  • Why the aggregate is the most powerful tactical pattern
  • How to size and structure aggregates
  • The role of the aggregate root
  • Understanding aggregate consistency guidelines

Wrox.com Code Downloads for this Chapter

The wrox.com code downloads for this chapter are found at www.wrox.com/go/domaindrivendesign on the Download Code tab. The code is in the Chapter 19 download and individually named according to the names throughout the chapter.

A domain model’s structure is composed of entities and value objects that represent concepts in the problem domain. It is, however, the number and type of relationships between domain objects that can cause complexity and confusion when implementing a domain model in code. Associations that do not support behavior and exist only to better reflect reality add unnecessary complexity to a domain model. Associations that can be traversed in more than one direction also increase complexity. This is why designing relationships between domain objects is equally as important as designing the domain objects themselves.

Even when all associations in a model are justified, a large model still has technical challenges, making it difficult to choose transactional and consistency boundaries that both reflect the problem domain and perform well.

This chapter covers best practices for keeping the relationships between domain objects simple and aligned with ...

Get Patterns, Principles, and Practices of Domain-Driven Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.