Contact Me

Bounded Context

Different parts of the domain of business

 It is a specific domain or area of the business or problem space that has its own distinct boundaries, meaning and concepts. It is a way of isolating and encapsulating a specific part of the system, and applying a specific set of ubiquitous language, rules and models to that part.

 Bounded contexts help to manage complexity by breaking down a large and complex domain into smaller, more manageable parts. Each bounded context has its own set of models and concepts, and the relationships between these models and concepts are specific to that context.

 For example, in an e-commerce system, you may have a bounded context for inventory management, which would have its own set of models and concepts such as Product, Stock, Inventory, and Order. Another bounded context could be the one for customer management, this context would have models like Customer, Order, Payment, and so on.

boundedContextImage



In JavaScript, you can implement bounded context by creating different modules for different contexts and each module will have its own set of classes and functions, here are some examples.

// inventory context

class Product {

constructor(name, stock) {

  this.name = name;

  this.stock = stock;

}

}

class Stock {

constructor(product, quantity) {

  this.product = product;

  this.quantity = quantity;

}

}

// Shipping context

class Customer {

constructor(name, email) {

  this.name = name;

  this.email = email;

}

}

class Order {

constructor(customer, items) {

  this.customer = customer;

  this.items = items;

}

}

 By isolating different parts of the system into their own bounded contexts, it makes it easier to understand, develop, test and maintain the system. It also makes it possible to evolve and change different parts of the system independently, without affecting the other parts.