The Repository Pattern

archetype Library and ArchiveSoftware Abstraction

Categories: software-engineering

What It Brings

A repository is a place where things are deposited for safekeeping and later retrieval. The word comes from Latin repositorium — a storehouse, a vessel. Libraries are repositories of books. Archives are repositories of records. Museums are repositories of artifacts. Fowler’s Repository pattern maps this onto data access: a repository object mediates between the domain layer and data mapping layers, acting as an in-memory collection of domain objects that happens to be backed by a database.

Key structural parallels:

Where It Breaks

Expressions

Origin Story

The Repository pattern was named by Martin Fowler in Patterns of Enterprise Application Architecture (2002), though the concept has roots in earlier object-oriented persistence frameworks. Eric Evans gave it canonical status in Domain-Driven Design (2003), where the Repository became a first-class tactical pattern for isolating domain logic from infrastructure. Evans emphasized the collection metaphor: a Repository should feel like an in-memory set of objects, even though it mediates access to a database. The pattern became a pillar of DDD and later a standard layer in virtually every enterprise application framework — Spring Data, Entity Framework, and countless ORMs provide repository abstractions out of the box.

References

Related Mappings