29.11.08

Why the Repository Pattern Sir?

When applying domain driven design, the repository pattern yields the following benefits:
* Represents all objects of a certain type as a conceptual set
* Provides access to roots of aggregates
* Can return summary information
* Provides mechanism for object add/delete
* Encapsualates DB access technology and strategy
* Answers the question, "How do I get a handle to an object" - done via object traversal, direct query execution to find object
* Clients of the repository interface use query based methods to get objects
* Repository is a first class client to object factories. The repository interface can encapsulate factories.
* Simplifies mock testing

Interface based repository implementations promote substitutability which is a naturally results in highly configurable and loosely coupled software architectures as in Liskov Substitution.

No comments: