Slide 1

Slide 1 text

Denis 2022 Build a scalable, modularized, testable app from scratch From Android Developers

Slide 2

Slide 2 text

Architecture

Slide 3

Slide 3 text

Architecture(1) Domain Layer (optional) UI Layer Data Layer

Slide 4

Slide 4 text

Architecture(2) UI Data Displays data Reacts to changes Business logic Obtains and exposes data Data Events Reactive UI Single source of truth

Slide 5

Slide 5 text

Data Layer

Slide 6

Slide 6 text

Data Layer(1) Repository Data source Exposes data Centralizes changes Obtains data

Slide 7

Slide 7 text

Data Layer(2) Repository NetworkDataSource LocalDataSource Repository REST API DataStore

Slide 8

Slide 8 text

Data Layer(3) O ff l ine- fi rst architecture Repository NetworkDataSource LocalDataSource Sync

Slide 9

Slide 9 text

UI Layer

Slide 10

Slide 10 text

UI Layer(1) Screen State holder Displays UI state Handles UI logic Constructs UI state

Slide 11

Slide 11 text

UI Layer(2) UI element ViewModel Repository Repository Jetpack Compose

Slide 12

Slide 12 text

UI state composition(1) Repository A Repository B ViewModel UI state Combines/handles data from repositories Loading

Slide 13

Slide 13 text

UI state composition(2) Repository A Repository B ViewModel UI state Done Update UI state

Slide 14

Slide 14 text

Modularization

Slide 15

Slide 15 text

Type of module Responsible for Depends on :app :feature :core Bring features together Single user-facing functionality Single area of common functionality :feature :core :core :core

Slide 16

Slide 16 text

https://developer.android.com/topic/modularization

Slide 17

Slide 17 text

Testing

Slide 18

Slide 18 text

Test dependencies ViewModel Interface Implementation Repository Interface A Repository Interface B Network-DataA-Repository Test-DataA-Repository Local-DataB-Repository Test-DataB-Repository https://developer.android.com/training/testing/fundamentals/test-doubles

Slide 19

Slide 19 text

• Building a scalable, modularized, testable app from scratch • https://developer.android.com/topic/architecture • https://developer.android.com/topic/modularization • https://developer.android.com/topic/modularization/patterns • https://developer.android.com/training/testing/fundamentals/ test-doubles • https://github.com/android/nowinandroid References