Unit 02 of 02
The Data Layer
The repository pattern, the local database, key–value storage, file and media storage, the network client, caching and offline support, paged data loading and background work.
Published Updated
Lessons
- 01 The Repository Pattern The repository pattern hides where data comes from by ordering local and remote data sources behind a single interface. The lesson measures the origin of an answer in an ordered lookup chain and shows how the origin changes when the order changes. 10 min read
- 02 Local Database A local database keeps the data of an application on the device disk through entities and data access objects, and a migration carries old rows to the new schema when the schema changes. The lesson measures the origin of a read after a migration and what a new column falls to in old rows. 8 min read
- 03 Key–Value Storage A key–value store keeps small preferences under a single key; reads and writes are asynchronous, and the value arrives as a flow. The lesson measures the origin of a read of a preference that was never written and how that origin changes when the user writes it. 8 min read
- 04 File and Media Storage An application reaches the files in its own directory directly and the media of others through the media store and permission rules. The lesson measures the origin of a read of a file in the app-specific directory and what a file that does not enter the chain falls to. 9 min read
- 05 The Network Client A network client defines a request, passes it through interceptors, and decodes the incoming response with serialization; the decoded fields build the network tier of the read. The lesson measures the origin of a read of a decoded response and what a cached response and a field that cannot be decoded fall to. 8 min read
- 06 Caching and Offline Support In the single source of truth pattern the UI reads only the local database, and the network only refreshes the database. The lesson measures the origin of a read after a refresh, that the origin stays the same while the value goes stale when the network goes down, and what a key that is not on disk at all falls to. 9 min read
- 07 Paged Data Loading A long list is loaded not all at once but page by page; each page is requested with a page key. The lesson measures the origin of a read of an item on a page that has not yet been loaded, how the origin changes when the page is loaded, and the same item coming from the network or from disk. 9 min read
- 08 Background Work A deferrable job, once its constraints are satisfied, pulls from the network and writes to disk, and the next read of the screen comes from disk. The lesson measures the origin of the read once the constraints are satisfied, what the read falls to when they are not, and the distribution of origins across the fourteen lessons of the course. 12 min read