Repository pattern
An interface shaped like a collection of domain objects that hides where the data is stored.
Definition
A repository offers lookups by id, finders named after what the app needs, and save and delete, and returns the app's own domain models. Behind it, implementations talk to a database, a server or a cache, and on mobile it decides which source answers. Screens and use cases depend only on the interface, so tests use in-memory fakes, kept honest by contract tests run against both the fake and the real implementation.
In practice
OrderRepository.recentOrders(customerId, limit = 20) runs one SQL query instead of loading every order.