Mobile Aplication Development MVC Model
Mobile Aplication Development MVC Model
1. Classic MVC
2. Apple’s MVC or extended MVC for android
3. MVP
4. MVVM
5. Viper
As shown in the above architecture, the View can directly access the
Model but in a read-only mode - View shouldn’t change the state of the
Model. The controller can do this; however, the controller doesn’t react
to the View directly. View’s responsibility is to query the status and
receives the status of the changed Model. The controller is not
responsible for this transfer between the View and Model. The sequence
diagram makes it easier to understand the interaction between the View,
Model, and Controller:
The controller comes into picture only when there is a need to render the
new View. For example, if you just want to update the View in order to
display the data in another format, the controller could do this without
requiring an update in the Model. Most of the server-side frameworks
include some kind of classic MVC implementation. For example,
Angular is a well-known full-fledged MVC framework.
The Controller sends the message to the Model based on the incoming
request invoked by the View. Model communicates the changes in the
state to the controller and the controller updates the changes to the View
object. The communication between the Model and View are indirect
through the controller. The View doesn’t bother about how the actions
are performed but maintain GUI representation and delegates
application-specific decisions of the interface behavior to the controller.
Though you can discharge some of the business logic to the View from
the Model, you have less chance to initiate the offloading, since most of
the time the View is busy in sending the user actions to the controller. In
addition, the controller is responsible for everything and hence the size
of the controller gets increased. In addition, when the View is tightly
coupled with the controller, it becomes harder for the unit test.
MVP Architecture
Does this pattern look similar to Apple’s MVC? But it is not. Here the
Presenter serves as the mediator between the Passive View and Model.
Unlike Apple’s MVC, the Presenter and Passive View are not tightly
coupled with each other. The View is made passive and it is not
responsible for updating itself based on the changes in the Model.
Presenter updates the data and the state of the View.
It addresses the above concerns of the MVC patterns. In addition, the
subclasses UIViews and UIViewController are present in Passive View
not in the Presenter. Let us look into the sequence of communication in
MVP:
MVVM Architecture
The next iteration to this approach, which resolves the above issue, is
MVVP (Model View ViewModel). John Goosman announced this
pattern in 2005. It is the most recommended pattern for Android
application development. This pattern is derived from the MVC pattern
and addresses the issues of previous MV (X) patterns. Let us explore the
MVVM architecture pattern:
Viper Architecture