1. The Architectural Evolution Interviewers often ask you to compare patterns to see if you understand their history and trade-offs.
2. Core Architecture Basics (The "Must-Knows")
Expect questions on these Android Jetpack components that support your architecture:
ViewModel: How does it survive configuration changes? (Answer: It’s stored in a ViewModelStore which is retained by the system during rotation).
LiveData vs. StateFlow: * LiveData is lifecycle-aware by default but is Android-specific.
StateFlow (Kotlin) is better for pure Kotlin logic and requires an initial state, but needs repeatOnLifecycle to be lifecycle-safe in the UI.
Repository Pattern: Acts as a mediator between different data sources (API, Database, Cache) so the ViewModel doesn't care where the data comes from.
3. Kotlin Coroutines (The Modern Way)
This is usually where the "Deep Dive" happens. You should be able to explain these concepts clearly:
The Basics
What are they? Lightweight threads. They are "suspendable" computations, meaning they can pause without blocking the actual thread.
Suspend Functions: A function marked with suspend can be paused and resumed later. It can only be called from another suspend function or a coroutine.
Coroutine Components
Dispatchers: Tell the coroutine where to run.
Dispatchers.Main: UI operations.
Dispatchers.IO: Networking, Disk (DB) operations.
Dispatchers.Default: CPU-intensive tasks (sorting, parsing).
CoroutineScope: Defines the lifetime of the coroutine (e.g., viewModelScope, lifecycleScope).
Job: A handle to the coroutine. Use it to cancel() or check if it’s isActive.
Advanced Scenarios
launch vs async: * launch is "fire and forget" (returns a Job).
async returns a Deferred and is used when you need a result back (using .await()).
Structured Concurrency: The principle that new coroutines can only be launched in a specific CoroutineScope which delimits its lifetime. If the parent scope is cancelled, all children are cancelled.
4. Common "Scenario" Questions
"How do you handle a network call in a ViewModel?"
Approach: Launch a coroutine in viewModelScope, switch to Dispatchers.IO (usually in the Repository), use a try-catch or a Result wrapper for errors, and update a StateFlow to reflect the UI state (Loading, Success, Error).
"What happens to a coroutine if the user rotates the screen?"
Approach: If using viewModelScope, the coroutine continues running because the ViewModel is not destroyed. If using lifecycleScope in an Activity, it will be cancelled.