SOLID & Design Patterns Interview Question #120
What is Event Sourcing?
Architectural Patterns, Application Boundaries & Distributed Design Patterns Senior Advanced
Quick Interview Answer
Event Sourcing stores a sequence of domain events as the authoritative history of an aggregate instead of storing only its latest state. Current state is reconstructed by replaying those events, often with snapshots for efficiency.
Detailed Explanation
Event Sourcing stores a sequence of domain events as the authoritative history of an aggregate instead of storing only its latest state. Current state is reconstructed by replaying those events, often with snapshots for efficiency.
It provides a strong audit history and temporal information but adds substantial complexity in event versioning, projections, storage, and operational tooling. It should not be selected merely because an application uses events.
Code Example
OrderCreated
ItemAdded
ItemAdded
OrderConfirmed
// Replaying these events reconstructs
// the current Order state.