
I’ll quickly share my understanding on these 2 architectures.
MVC
- A View can be the ui elements like TextView in XML, TextField, Button in Jetpack Compose. The view then either sends an event to, or is updated by, the Controller.
- The controller is the Activity. The Activity interacts with the models.
- Models are use cases data classes or POJOs, network requests, or any io operation modules interface.
Activity -> Models
- The UI and Models are tightly coupled, making it hard to test the code.
- Therefore MVC is good for small projects.
MVP
- A View is Activity that implements an interface that contains all the actions within the screen. Actions like performLogin, checkout, refresh, loadItems, viewItemDetails etc
interface LoginView {
fun performLogin()
..
}
interface CheckoutView {
fun checkout()
fun refresh()
fun loadItems()
fun viewItemDetails()
..
}
- The Presenter contains the actual steps required to complete the action, like performing network call, moving between screens, etc
- Models are use cases, data classes or POJOs, network requests, or any io operation modules interface.
Activity -> Presenter -> Models
- MVP is good for testing as it decouples UI and Models. As the testing is good in MVP the project eventually becomes scalable.
- MVP is good for large projects.