Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

Difference Between MVC and MVP Architecture Pattern in Android

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Developing an android application by applying a software architecture pattern is always preferred by the developers. An architecture pattern gives modularity to the project files and assures that all the codes get covered in Unit testing. It makes the task easy for developers to maintain the software and to expand the features of the application in the future. MVC (Model — View — Controller) and MVP (Model — View — Presenter) are the two most popular android architectures among developers.

The Model—View—Controller(MVC) Pattern

The MVC pattern suggests splitting the code into 3 components. While creating the class/file of the application, the developer must categorize it into one of the following three layers:

Model: This component stores the application data. It has no knowledge about the interface. The model is responsible for handling the domain logic(real-world business rules) and communication with the database and network layers.

View: It is the UI(User Interface) layer that holds components that are visible on the screen. Moreover, it provides the visualization of the data stored in the Model and offers interaction to the user.

Controller: This component establishes the relationship between the View and the Model. It contains the core application logic and gets informed of the user’s behavior and updates the Model as per the need.

The Model—View—Controller(MVC) Pattern

The Model—View—Presenter(MVP) Pattern

MVP pattern overcomes the challenges of MVC and provides an easy way to structure the project codes. The reason why MVP is widely accepted is that it provides modularity, testability, and a more clean and maintainable codebase. It is composed of the following three components:

Model: Layer for storing data. It is responsible for handling the domain logic(real-world business rules) and communication with the database and network layers.

View: UI(User Interface) layer. It provides the visualization of the data and keep a track of the user’s action in order to notify the Presenter.

Presenter: Fetch the data from the model and applies the UI logic to decide what to display. It manages the state of the View and takes actions according to the user’s input notification from the View.

Model—View—Presenter(MVP) Pattern

Key Differences Between MVC and MVP Design Pattern

MVC(Model View Controller)

MVP(Model View Presenter

One of the oldest software architectureDeveloped as the second iteration of software architecture which is advance from MVC.
UI(View) and data-access mechanism(Model) are tightly coupled.The View is loosely coupled to the Model.
Controller and View layer falls in the same activity/fragmentCommunication between View-Presenter and Presenter-Model happens via an interface.
User inputs are handled by Controller which instructs the model for further operations.User inputs are handled by View which instructs the presenter to call appropriate functions.
The many-to-one relationship exists between Controller and View as one Controller can select different View based upon required operations.The one-to-one relationship exists between Presenter and View as one Presenter class manages one View at a time.
The Controller is the overall in charge as it creates the appropriate View and interacts with the Model according to the user’s request.The View is the overall in charge in this schema as View call methods of Presenter which further directs Model.
Limited support to Unit TestingUnit Testing is highly supported.
My Personal Notes arrow_drop_up
Last Updated : 10 Nov, 2020
Like Article
Save Article
Similar Reads