System Design
15. Software Design PatternsAnimated walkthrough
Repository Pattern
A collection-like interface to data storage.
The idea
Hides database details so the domain reads and saves objects through a repository.
Watch it work
The steps light up one at a time. Use the controls to pause or step through.
- 1Define a repository interface
- 2Implement it for the database
- 3Domain code calls it
- 4Swap implementations in tests
1/4
Step by step
- 1Define a repository interface
- 2Implement it for the database
- 3Domain code calls it
- 4Swap implementations in tests
Where it is used
Data access layers.
Watch out for
Leaky abstractions over complex queries.