Repository Flashcards

1
Q

Which 3 “concerns” ought to remain separated in different components?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 4 methods of caching in Android

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Give syntax for a good way of converting a list of object of one type to a list of objects of a similar type

A
fun List^MyObject^.asListOfSimilarObjects( ): List^MySimilarObject^ {
  return map{
    MySimilarObject(
    val1 = it.val1
    ...
  }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. What is a repository?
  2. Give 3 examples of data sources.
  3. What is the repository pattern?
A
  1. Repository: mediates between data sources.
  2. Data sources:
    persistent models, web services, caches
  3. 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly