Saturday 6 September 2014

Generic Repository pattern - or not?

I've often wondered if one should really be using Generic Repositories or not...

And from my research it seems like the answer is the same as to many other programming questions: it depends on the context of the problem you're trying to solve.

Instead of repeating other well put together discussions, here are some links to some of the more poignant opinions that I use to assist in determining if a generic repository is appropriate or not:

Say No to the Repository Pattern in your DAL

Repositories On Top UnitOfWork Are Not a Good Idea

and

The generic repository is just a lazy anti-pattern

The thing i like about the last link is that it gives a small example of when a generic repository can useful:

A generic repository does have a place, but as a helper for internal access used within a public-facing repository implementation. The trick is not to expose a generic interface but achieve re-use through composition.

No comments:

Post a Comment