Domain-Driven Design (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
How should Aggregate boundaries be sized?
senior LevelSystem Design
In Simple Words:
The #1 beginner mistake in DDD is creating massive, bloated aggregates (e.g. a Customer aggregate containing all historical orders, invoices, reviews, and tickets):
- Large aggregates cause severe database locking contention, high memory consumption, and transaction deadlocks!
- Best Practice (Small Aggregates):
- Make aggregates as small as possible while preserving strict immediate business invariants.
- References between independent aggregates should be by ID only (
customerId: CustomerId), never direct object pointers! - Use Eventual Consistency across aggregates via Domain Events.