Why to use the Repository Pattern?

There are a lot of reasons for using the Repository Pattern. For example

  • Testability. Using the pattern we can create stubs that can replace the real data access objects. This can help us to test our business logic without concerning what the data access is doing.
  • Abstraction. Using the pattern we create an abstraction above our data access functionality. This abstraction can help us when we want to change the implementation of the data access without affecting our business logic code. For example, I had to change implementation of data access with a call to a web service. Using the pattern I only needed to change the object that I used and that is  it.
  • Dependency Injection. Using the pattern we can use DI containers to inject the relevant object that we want to use in the code.

There are a lot of reasons for using the Repository Pattern. For example Testability. Using the pattern we can create stubs that can replace the real data access objects. This can help us to test our business logic without concerning what the data access is doing. Abstraction. Using the pattern we create an abstraction above…

Leave a Reply

Your email address will not be published. Required fields are marked *