Architecture Expert
DDD Bounded Contexts — Domain Boundaries¶
DDDBounded ContextDomain 3 min read
How to define bounded contexts in Domain-Driven Design. Context mapping and ubiquitous language.
What is a Bounded Context?¶
An explicit boundary within which a domain model has a clear meaning. The same term can mean something different in different contexts.
- Sales: Customer = buyer, shopping cart, preferences
- Shipping: Customer = delivery address, phone number
- Billing: Customer = billing details, tax ID
Ubiquitous Language¶
Within each BC, a unified language exists — developers and domain experts speak the same way.
// Sales Context
class Order {
items: OrderItem[];
applyDiscount(code: string): void;
calculateTotal(): Money;
}
// Shipping Context — different language
class Shipment {
recipient: Recipient;
packages: Package[];
estimateDelivery(): Date;
}
Context Mapping¶
- Partnership — collaboration between two teams
- Customer-Supplier — upstream provides API
- Anti-Corruption Layer — translation of a foreign model
- Open Host Service — standardized API
Summary¶
Bounded Contexts are the most important concept in DDD. Correct boundaries lead to cleaner architecture and less coupling. Start with an Event Storming workshop.
Need Help with Implementation?¶
Our team has experience designing and implementing modern architectures. We’re happy to help.