Home  /  Questions  /  Question



50   50
May 15, 2011


Best location of Repository layer

In the 'Patterns in Action' example, I noticed that the Repository layer is accessed in the controllers. The Microsoft architecture evangelists like Scott Millet, Dino Esposito suggest a layer between the controllers and Repository. Based on their suggestions, the architecture will look like:

UI (View)
Controllers
Service (Request and Response)
Repository
WCF service
BLL
Repository
DAL

What do you think?




830   99.9
May 16, 2011
Varghese:

The Repository is an API Pattern (i.e. interface pattern), rather than a specific layer.
Anyhow, the best architecture is whatever works best for your situation.

The main criteria to keep in mind for these and many other architectural decisions are future changes. If you anticipate changes (change requests always occur), you want an architecture that is flexible and allow you to implement these effectively and efficiently, without breaking exising code (i.e. tested code).

Hope this helps.
Dan
 1 comment
 
Thanks for clarifying the layer vs pattern aspect. The many layers as shown in the original post helps low coupling and high cohesion. That helps to unit test each layer. The effect of change requests to one layer has direct or indirect impact to other layers. So, I think you have to make sure all unit tests have passed instead of just a single unit test, and correspondingly a regression test is necessary of the whole software. --- Varghese Pallathu  May 16, 2011