DDD and bounded contexts
Let a model mean one thing inside a clear boundary.
The problem and the pattern
Booking calls a customer the person holding seats. Billing calls a customer the account responsible for payment. These concepts share an identifier but have different rules and lifecycles. A bounded context names where a language and model apply; translation makes the boundary explicit.
Follow the flow
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
public sealed record BookingCustomer(string CustomerId);
public sealed record BillingAccount(
string CustomerId, string Currency, bool CreditApproved);Trade-offs
- Context boundaries follow business meaning, not database table count.
- Eventual consistency may be needed between contexts.
- An anti-corruption layer prevents an external model from taking over local rules.
When to avoid it
Avoid deep tactical DDD machinery when the domain is straightforward data entry with little business complexity.
Your turn
A team proposes one shared Customer entity for booking and billing. What changes would expose the coupling?
Reveal a worked answer
A billing credit rule or currency requirement would force booking to understand billing behavior. Keep each context model focused and translate identifiers and facts at their integration boundary.