Search code examples
javadomain-driven-designmicroservices

What does bounded context mean in Microservices World?


I have been learning to implement Microservices but I could not understand the term "bounded context"?

I could understand that it is concept which arises out of Domain Driven Design. But I could not understand the technical implementation of it.

I have looked at below links:

  1. microservices and bounded contexts
  2. https://martinfowler.com/bliki/BoundedContext.html
  3. https://learn.microsoft.com/en-us/dotnet/standard/microservices-architecture/microservice-ddd-cqrs-patterns/microservice-domain-model

Solution

  • It is the biggest zone/area/place where a term has a consistent meaning (it means the same thing for the business specialists and the developers). I intentionally avoided using the word "context". Ideally, a Bounded context is exactly a Domain from the real world.

    When it comes to microservices, a microservice should not be larger than a Bounded context.

    UPDATE

    A Bounded context should be an independent domain, if the system is correctly designed; in reality, when things are not done correctly, a Bounded context is larger than a domain. In large enterprises, some developers create objects (models) that try to capture all the behavior related to some term. For example, Product in a Shop. This term is very broad. The Product from the online-shop and the Product from the inventory system are not one and the same thing, although they may seem that way. In this case, the online-shop should be bounded context and the inventory should be a different one.

    Implementation

    Each "product" should have a different class in each bounded context, for example. A bounded context can be implemented as (a better expression would be "can be seen as") a namespace or package in monoliths, or as a microservice in distributed systems.