Android App Architecture
By - Thiyagaraj M & Godlin Josheela Rani S
Model View Controller (MVC)
The view is directly coupled with business logic which is nothing but the controller.
Adding new functionalities with existing code is complex as the view class file(Activity/Fragment) itself will have to hold nearly 1000+ lines of code.
After performing business logic, the view has to be updated manually.
Code understanding and hand over is difficult.
Advantages of MVC architecture:
App Development is fast.
Multiple developers can collaborate and work together easily.
Minor changes in application can be update easily.
Disadvantages of MVC architecture:
It is hard to understand for other developers to make changes in code.
Must have strict rules on methods or else code maintenance will become complex.
Model View View-Model (MVVM)
View and model are not connected at all.
View model handles 2-way coupling. Once data is changed in the view model, the data automatically changes in the model and also view automatically.
Code handover and understanding is easy.
App performance will be improved as we do not have to update view manually every time.
In MVVM pattern Android Jetpack libraries like Data binding, ROOM database, etc.. must be used for better usage of Live Observable data of View models.
Advantages of MVVM Architecture
Application code is even more easily understandable than other architectures.
Application code is further decoupled (the biggest advantage.)
The package structure is even easier to navigate.
The project is even easier to maintain.
Development team can add new features even more quickly.
Disadvantages of MVVM architecture:
It has a slightly steep learning curve. Understanding how various layers work together may take some time, especially when coming from patterns like simple MVC or MVP background.
It adds a lot of extra classes, so it is not ideal for low-complexity projects.
MVVM can be hard to design for the ViewModel up front in order to get the right amount of generality.
Notes for Architecture Migration MVC to MVVM
Development time for MVVM is higher in comparison to MVC.
Conversion from MVC to MVVM takes approximately the same time as developing a new app using MVVM pattern as the only reusable code from MVC will be the models.
Conversion is more complex , Developers need lot of time to replace all components to Jetpack Libraries and Room data base.