
Feature Name | Description |
---|---|
What is Domain-Driven Design? |
Domain-Driven Design (DDD) is a software design method wherein developers construct models to understand the business requirements of a domain. These models serve as the conceptual foundation for developing software. Developers need to collaborate with domain experts to guarantee that the code is aligned with business rules and client needs. |
Bounded Context (BC) |
A bounded context (BC) is the space in which a term has a definite and unambiguous meaning. The problem is that the larger the domain, the more difficult it is to find a consistent and unified model. DDD’s solution is to identify BCs so that the domain can be broken down into manageable subdomains. |
Context Map |
The presence of a BC anticipates the need for communication channels. For instance, if we’re working in an e-commerce domain, the salesperson should check with inventory before selling a product. And once it’s sold, it’s up to shipping to ensure delivery of the product to the correct address. In DDD, these relationships are depicted in the form of a context map.
Picture
![]() |
Domain-Driven Design for microservices |
DDD takes place in two phases:
|
Strategic phase |
During this phase, we invite developers, domain experts, product owners, and business analysts to brainstorm, share knowledge and make an initial plan. In strategic DDD, we take a high-level, top-to-bottom approach to design. We begin by analyzing the domain in order to determine its business rules. From this, we derive a list of BCs. |
Types of relationships |
Next, we must decide how BCs will communicate. Eric Evans lists seven types of relationships, while other authors list six of them. Regardless of how we count them, at least three (shared kernel, customer/supplier, and conformist) imply tight coupling, which we do not want in a microservice design and can be ignored. That leaves us with four types of relationships:
|
Tactical phase | this stage, which requires developers well-versed in DDD theory, we’ll zoom in on each context to construct a detailed model.
The models created with DDD are technology-agnostic — they do not say anything about the stack underneath. We focus, instead, on modeling the subdomain. The main building block of our models are:
|
Domain-Driven Design is iterative | On paper, bounded contexts and context maps may appear OK, but when implemented, they may translate into services that are too big to be rightly called microservices. Conversely, chatty microservices with overlapping responsibilities may need to be merged into one. Other methods such as Test-Driven Development (TDD) or Behavior-Driven Development (BDD) may be enough for smaller, simpler systems. TDD is the fastest to start with and works best when working on single microservices or even with applications consisting of only a few services. |