janishar / android-mvp-interactor-architecture

Extension of the android-mvp-architecture for very large projects.
Apache License 2.0
404 stars 97 forks source link

Why do you use Repository pattern just over database only but not also over remote API? #6

Closed GregPetrov closed 7 years ago

GregPetrov commented 7 years ago

Thanks for code sharing! Many architecture blueprints I saw (google samples MVP for example) implement repository pattern incapsulating also API calls under repository CRUD methods. Please, describe why you considered not implement repository pattern the same way? Thank you.

janishar commented 7 years ago

@VanZaant This was done so that the APIs and DB are handled separately. They only are responsible for their own roles and independent of any other application components.

  1. It makes the application loosely coupled with each component having their independent roles.
  2. It allows us to make any external libraries replaceable with ease.
  3. It makes testing easier.
  4. It makes the architecture modular.
GregPetrov commented 7 years ago

@janishar Thanks for your answer! Have a nice day!