6 Maintaining the Integrity of Domain Models with Bounded Contexts

WHAT’S IN THIS CHAPTER?

  • The challenges of a single model
  • The importance of the bounded context
  • Carving out and defining boundaries of responsibility in code
  • Protecting the integrity of core parts of the domain
  • Where to define boundaries

In large and complex applications you will find multiple models at play. Each model will be built to represent a distinct area of the problem domain, with each implementation using an appropriate code design pattern suitable for the complexity of the problem. Ideally you will have a model for each subdomain; however, this might not always be the case as some complex subdomains could contain more than a single model and some models could span two or more subdomains. No matter how many models you have you will find that they will need to interact to fulfill the behaviors of a system. It is when models are combined by teams without a clear understanding of what context they apply to that they are prone to become blurred and lose explicitness, as concepts and logic are intermingled.

Therefore it is vital to protect the integrity of each model and clearly define the boundaries of their responsibility in code. This is achieved by binding a model to a specific context, known as a bounded context. A bounded context is defined based on team’s language, and physical artifacts. Bounded contexts enable a model to stay consistent and meaningful, which is vital in managing complexity in ...

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.