Repository Pattern

repository pattern image

Definition
Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects (martin fowler).

Applicability
  • When you want to isolate domain objects from details of database access code.
Consequences
  • Acting like an in-memory domain object collection
  • Providing a more object-oriented view of the persistence layer
  • A clean separation and one-way dependency between the domain and data mapping layers.


Downsides
  • DDD repository is limited to aggregate roots only
  • Hides  persistence storage  features behind a repository interface which sometimes is limiting


Sample Code


References
http://martinfowler.com/eaaCatalog/repository.html
http://ayende.com/blog/3955/repository-is-the-new-singleton

Comments

Popular Posts