| name | domain-driven-design |
| description | DDD tactical and strategic patterns. Use for complex domains. |
Domain-Driven Design (DDD)
DDD is a software design approach focusing on modeling software to match a domain according to input from that domain's experts. It is essential for tackling high complexity in the heart of software.
When to Use
- Complex business domains (e.g., Insurance, Banking, Logistics) where logic is intricate.
- When there is a communication gap between developers and business experts.
- decomposing a Monolith into Microservices (defining boundaries).
Quick Start
public class Order {
private OrderId id;
private Money totalAmount;
private OrderStatus status;
private List<OrderItem> items;
public void addItem(Product product, int quantity) {
if (this.status != OrderStatus.DRAFT) {
throw new DomainException("Cannot modify confirmed order");
}
this.items.add(new (product, quantity));
recalculateTotal();
}
{
(items.isEmpty()) ();
.status = OrderStatus.CONFIRMED;
DomainEvents.publish( (.id));
}
}