1 minute read · architecture
DDD aligns code structure with business concepts reducing cognitive load.
Key Concepts
- **Bounded Context** — clear module boundary
- **Aggregate** — consistency boundary within a context
- **Domain Event** — something that happened in the domain
Example Aggregate
class Order {
private items: OrderItem[] = [];
addItem(product: Product, qty: number) {
// invariants enforced here
this.items.push(new OrderItem(product, qty));
this.raise(new ItemAddedEvent(product.id));
}
}Conclusion
DDD pays off on complex domains. Avoid it for simple CRUD apps.