Feedback: Usage of Repository Pattern

Jan 13, 2012 at 3:48 PM

Thanks for the awesome work!

Here are few inputs regarding the way repository pattern being used here:

  • By definition a repository is: Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects. So only Add, Remove and some get methods (possibly like Specification pattern) should be used. Few of repositories implemented in silk includes "Update" method, which is violation of the main concept of repository pattern. Seems like Repository in silk is responsible to handle Database CRUD here, which is not main focus to repository pattern. If you really need to have a layer which will isolate CRUD, give another name (for instance DataProvider)
  • A real benefit of Repository pattern is, it helps to identify aggregate root, by which the child model classes will be accessed. Repositories should not be implemented "per data model" basis. 
  • Do we really need a repository specific layer? In the early stage of Entity Framework, which had "heavy weight" data containers, developers needed a separate layer for Persistence Ignorance (PI). Since we can easily reach to PI thru Entity Framework Code First approach, where the DbSet can be considered as Repositories and SaveChages method can be considered as UnitOfWork pattern implementation in PI fashion, adding complete additional layer for repository may overkill the design.

I think if the points mentioned above are taken consideration, the overall design would move forward to a better level. However, if the team have different view point from these, would like to hear from the team as well. 

Jan 13, 2012 at 6:12 PM


Thanks for your suggestions, I found you also commented in this related work item. Based on my understanding, as these are related to design issues, it would be better to continue the discussion there, so the team can analyze them for future releases.


Agustin Adami

Jan 13, 2012 at 7:43 PM


Thanks for the quick response.

The context  of the design in the work item that you mentioned is slightly different than context that has been mentioned in the current thread. Repository Pattern is one of the most known buzzword that often been misused in last few years, thus really need some special attention. Specially after the release of EF Code First, I think this is the best time to re-think the design considerations and decisions about Repository pattern to be implemented in ASP.NET MVC context.

Silk is really an wonderful work that I have seen so far. Taking a thoughtful discussion between community and Silk team - regarding better/alternative implementation of Repository pattern may possibly lead to a great design decision.  And if we can really achieve that it will place a significant contribution towards the community, since Silk is a project from Microsoft pattern & practices, and are being/will be followed by thousands of people in developer community.

Looking forward to hear from the team.