Using MVC and MVP in Jetpack Compose
1. Can we use MVC or MVP with Jetpack Compose?
Technically, yes, you can use MVC or MVP in Jetpack Compose because they are just architecture patterns — rules about how to separate UI, logic, and data. Compose itself doesn’t restrict the pattern.
- MVC: You could have a Controller class handle logic and update Composables (the View).
- MVP: You could have a Presenter class handle all the logic and tell Composables what to display.
But there are important caveats...
2. Why MVC/MVP is not recommended with Jetpack Compose
- Compose is reactive: Composables automatically recompose when data changes. MVC and MVP were designed for imperative UI (XML + Activity/Fragment). Manually updating UI from Controller or Presenter can be verbose and go against reactive patterns.
- View in Compose is not traditional: In MVP, the View is passive and updated by the Presenter. In Compose, the Composable itself can observe state (State, MutableState, LiveData, or StateFlow) and update automatically — making Presenter unnecessary.
- Boilerplate: Implementing MVP or MVC in Compose often leads to extra classes and interfaces that don’t add much value. You end up writing more code than necessary.
3. Recommended Approach for Jetpack Compose
Use MVVM or MVI patterns:
- ViewModel holds the state.
- Composables observe state and automatically update when it changes.
- This leverages Compose’s reactive nature perfectly.
Example with MVVM:
val uiState by viewModel.uiState.collectAsState()
Text(text = uiState.username)
No need for a Presenter or Controller — state drives the UI.
4. TL;DR Comparison
| Pattern | Recommended with Compose? | Reason |
|---|---|---|
| MVC | ❌ Not advised | Imperative updates conflict with reactive Compose UI |
| MVP | ⚠️ Possible but not ideal | Presenter becomes unnecessary boilerplate |
| MVVM | ✅ Strongly recommended | Fits Compose’s reactive, state-driven design |
| MVI | ✅ Optional | Works well for unidirectional state flow |
Bottom Line
With Jetpack Compose, stick to MVVM or MVI. MVC/MVP is more suited for traditional XML + Activity/Fragment UI.