MVVM & Unidirectional Data Flow
ARCHITECTURE › Patterns
How ViewModels expose immutable UI state and drive the View via unidirectional data flow.
MVVM and UDF are the backbone of Android's official architecture guidance, so interviewers use them to probe whether you can structure a screen cleanly. Expect to defend why the ViewModel holds no Android references, how state flows down while events flow up, and how a single immutable UI state class becomes the screen's source of truth. You will often be asked to model loading, error, and empty states without introducing inconsistent or duplicated state.
What this covers
- Why the ViewModel must hold UI state plus logic but keep zero View, Context, or Android framework references
- Unidirectional data flow: state flows down to the View, events flow up to the ViewModel
- Modelling screen state as a single immutable data class that is the single source of truth
- Exposing state with observable holders (StateFlow or Compose State) and collecting it lifecycle-aware
- Representing loading, error, and empty states inside the UI state instead of as scattered flags
- Separating business logic (data/domain) from UI logic, and why only the state owner mutates state
Study this topic
- MVVM & Unidirectional Data Flow explained: the guided lesson
- 14 practice quiz questions
- 9 revision flashcards
- MVVM & Unidirectional Data Flow interview questions and answers