Posts

Showing posts with the label Android App Development

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

Image
  Architecture & Patterns Find Part -1 From Here Find Part -2 From Here 31. MVI Reducer? MVI Reducer (with Error Handling) Reducer in MVI is a pure function that takes the current State and an Intent and returns a new State . Key properties No side effects (no network, DB, coroutines) Deterministic and replayable 100% unit-testable State is immutable State @Immutable data class OrderState ( val items: List<OrderItem> = emptyList(), val loading: Boolean = false , val error: String? = null ) Intents (User + Result) sealed interface OrderIntent { data object Load : OrderIntent data object Retry : OrderIntent data class AddItem ( val item: OrderItem) : OrderIntent data class LoadSuccess ( val items: List<OrderItem>) : OrderIntent data class LoadFailure ( val message: String) : OrderIntent } Reducer (Pure) class OrderReducer { fun reduce (state: OrderState , intent: OrderIntent ) : OrderState = ...

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...