1

I'm trying to implement a business logic layer with a few use case for saving data of Booking of a Vehicle. I'm a bit confused as to where the Repository pattern should be implemented. Should I use it in BLL or DAL? It sounds very basic but I'm kind of lost in the design phase. If Repository pattern is not suitable for BLL, then which one is. Any help/tips are appreciated.

A.K
  • 505
  • 1
  • 12
  • 30
  • Repository classes should be part of Data Layer and Business layer will access those using abstraction(Interfaces). Repository classes will have generic CRUD operations. – Anupam Singh May 31 '15 at 12:29

1 Answers1

6

The repository patterns responsibility is to store and fetch data from the data layer and to make abstraction about how this data layer looks like. The idea behind it is that if this underlying layer should change, you would possibly need to change the implementation of the repository but not the users of the repository who would still see the same interface.
Remembering SOLID design rules and Single responsibility in particular, the repository should not have any business logic and therefore cannot be part of it. The business layer uses the repositories though.

Philip Stuyck
  • 7,344
  • 3
  • 28
  • 39
  • Thanks Philip, by "data layer" you mean, Data Access Layer? One question that is bothering me, is that is it okay for a Repository to have functions like `Booking GetBooking(string RegistrationNumber)`, would it violate any good practices? – A.K May 31 '15 at 12:25
  • That would be completely acceptable ( even encouraged ). But I would think on this. Does GetBooking(string) or Get(RegistrationNumber) convey better meaning. I suggest that using a RegistrationNumber type would be better. – Alistair May 31 '15 at 12:46
  • Appreciate the time and effort guys. Thanks for helping me clear my mind! – A.K May 31 '15 at 22:37