Design Patterns (GoF) (50 Qs)•Part 2: Behavioral Patterns & Communication (11 - 24)
What is the Event Sourcing Pattern?
junior LevelBehavioral
In Simple Words: Instead of storing only the current state of an entity, Event Sourcing stores the entire append-only sequence of immutable domain events that led to that state:
- Bank Account Balance is not stored as
$500. - Instead, the database stores:
AccountCreated (+$0)MoneyDeposited (+$1000)MoneyWithdrawn (-$500)
- Benefits: Perfect 100% audit log, time-travel debugging (replay events to inspect state at any second in history), zero update locks.