In the latest post, we discussed what a bounded context is in DDD. We also saw that models in different bounded contexts can evolve and be implemented independently. But are bounded contexts themselves independent? The answer is no. Although they can evolve independently, they still need to integrate with one another. To facilitate this integration, we need to use contracts that allow them to interact with each other. 🔄
In this post, we are going to explore the various patterns available for defining relationships and integrations between bounded contexts. These patterns will depend on the nature of the collaboration and how well the teams responsible for the bounded contexts collaborate with each other.
🔹 Partnership: Here, no strict contract is defined. Both sides cooperate in solving integration issues if there is a change in the API. This pattern might not be suitable for geographically distributed teams, as it may present synchronization and communication challenges. 👨💻
🔹 Shared Kernel: There is some part of the model that is shared and overlaps between the bounded contexts. This can sometimes be useful for integrating bounded contexts that are owned and implemented by the same team.
🔹 Conformist: In this pattern, the consumer conforms to the service provider's model. The supplier provides the integration contract, and the consumer must adapt accordingly.
🔹 Anticorruption Layer: This pattern applies when the consumer does not want to conform. The supplier's bounded context model is translated into a tailored model with its own needs via an anticorruption layer.
🔹 Open-Host Service: This pattern is ideal when the supplier is interested in protecting its consumers. The implementation model is decoupled from the public interface. Compared to the anticorruption layer, in this case, the supplier is responsible for implementing the translation.
🔹 Separated Ways: In this last pattern, there is no collaboration at all; functionality is simply duplicated. This should be avoided when integrating with core subdomains.
⭕ As you can see, bounded contexts are not independent. They must interact with one another to build the entire system.
Hope you liked today's post.