-
Notifications
You must be signed in to change notification settings - Fork 9
Repository Pattern
Developing apps usually we feed it with data from a BackEnd or BaaS, probably want to keep it working without internet so we need to store information in a Database or SharedPreferences and if we want to improve the performance we will need to implement a cache strategic.
So, we can have multiple sources of data and the true is that our views don't need to know that. For that we use the Repository Pattern to abstract the data source from the UI (our Activities/Fragments) or in case you use MVP from our Presenters.
As we can see in the image, the idea is to have a interface with generic methods and our View will have access to the data from it. To keep the code uncoupled we recommend to have one interface for each data source which will be used for the main Repository interface.