Repository Flashcards
Which 3 “concerns” ought to remain separated in different components?
A change to any one of these should not necessitate any changes in the others
Network - where the data is fetched from and how
Domain - data classes representing the app’s data
Database - schema’s structure
What are the 4 methods of caching in Android
Retrofit - can be configured to store a copy of every network result locally
SharedPreferences - can store a small number of k-v pairs
App’s internal storage - App’s package name specifies internal storage directory. Private to your app and cleared when app is deleted.
Room - a SQlite object-mapping library
Give syntax for a good way of converting a list of object of one type to a list of objects of a similar type
fun List^MyObject^.asListOfSimilarObjects( ): List^MySimilarObject^ { return map{ MySimilarObject( val1 = it.val1 ... } }
- What is a repository?
- Give 3 examples of data sources.
- What is the repository pattern?
- Repository: mediates between data sources.
- Data sources:
persistent models, web services, caches - Repository pattern: isolate data sources from the rest of the app. Provide an API for the rest of the app to access various data sources.