Posts

Showing posts from January 2, 2026

Cracking Android SDE2/SDE3 Interviews in 2026: Deep Dives, Code, Follow-ups | Part-2

Image
  Architecture & Patterns Find Part -1 From Here 21. MVVM vs MVI? Interviewer: Compare MVVM and MVI — when choose MVI? Candidate: MVVM: View observes ViewModel state (StateFlow/LiveData), unidirectional updates. Simple for CRUD. MVVM (Model–View–ViewModel) How MVVM works View observes state from ViewModel ViewModel exposes data via LiveData or StateFlow View calls functions directly on ViewModel State is often split across multiple variables Typical MVVM flow View → ViewModel.method() ViewModel → update LiveData / StateFlow View ← observes updates Example MVVM pattern class ProfileViewModel : ViewModel () { val loading = MutableStateFlow( false ) val profile = MutableStateFlow<Profile?>( null ) val error = MutableStateFlow<String?>( null ) fun loadProfile () { loading.value = true // fetch profile } } Problems MVVM faces at scale State is scattered Hard to know which user action caused which state Difficult t...