Back to list
Views:   12.3K
Replies:  2

Generic Repository-based interface

Hi there, I have a question:
Why is the generic Repository-based interface in the MVC Application project and why not in Data Layer project?

Yassin Khan, Nov 21, 2010
Reply 1

If you are talking about the Patterns In Action 4.0 MVC application, then it's there to provide a base implementation to the UI repositories.  The DoFactory guys can correct me if I'm wrong about this, but what this does in this particular pattern is provide a layer of abstraction in the UI for, what I see as three immediate reasons:

  1. WCF abstraction - the repository base abstracts away the actual implementation of the WCF proxy, so this way you aren't accessing it directly in the controllers.  The next reason explains why.
  2. Testability - by referencing repository interfaces instead of the WCF proxy client, you can now test your controllers, which in MVC is huge and necessary.
  3. DRY - Don't repeat yourself.  This class also provide access to a commonly used Correlate method that validates that your request and response matches.  You can also place other reusable methods here that help you process your code.
By designing the framework this way, they've given you access to WCF services and kept the controllers testable.  This is a "Win win".

I hope that answers your question.

King Wilder
King Wilder, Jan 07, 2011
Reply 2
I am not sure which context you are referring to, but as a general practice the "Generic Repository" interface should not be in the MVC application project.  It should be in a separate class library for ease of reuse and from maintenance point of view.
Rajesh Pillai, Jan 06, 2011
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.