-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Writing the hypotheses of the "hate" articles as issues and defending them should help us improve as professionals, but also to get to the bottom of all this hate! ;)
Let me start with Rob Conery's article. He starts
It's generally believed that by using the Repository pattern, you can (in summary) "decouple" your data access from your domain and "expose the data in a consistent way".
And refutes it with an MSDN code sample.
If you look at any of the implementations of a Repository working with a UnitOfWork (EF) – you'll see there's not all that much "decoupling":
... (code snippet)...
This class can't exist without the SchoolContext – so what exactly did we decouple here? Nothing.
He makes the following claim for named command/query classes over Repository.
Less Abstraction == Clarity. We've lost our Repositories which didn't have a reason to exist other than to abstract an existing abstraction. Our Command/QueryObject approach is cleaner and the intent of each one is clearer.
A few questions...
- Do we accept the Repository decoupling premise?
- Do we accept the sample as a prototypical implementation of Repository over EF?
- What is the definition of decoupling?
- Do we agree that decoupling is a "good thing"?
- Does the CQS pattern decouple? How?
Let's pull in Jimmy Bogard's argument about Repository being an unnecessary abstraction.
I don’t think creating an abstraction over your ORM provides much value... Instead of bloating a data access god class, why not just create an isolated class that encapsulates our query?
His solution, named command/query classes, invokes the terms "encapsulation", "isolation", and "dependency injection".
Are these related to coupling?