Illustration of the difference between MVC,MVP and MVVM

Source: Internet
Author: User

The MVC full name is Model view Controller, an abbreviation for Models-View-Controller (Controller), an example of software design, which organizes code by means of a business logic, data, and interface display.


MVC is one of the most common software architectures and is widely used in the industry. It's easy to understand, but to be clear, it's not easy to distinguish it from the derived MVP and MVVM architecture.


I. MVC

The MVC pattern means that the software can be divided into three parts.


View: User interface.

Controller (Controller): Business logic

Model: Data Preservation

The modes of communication between the parts are as follows.


View Transfer command to Controller

Controller completion of business logic, request Model change state

Model sends new data to View, user gets feedback

All communications are one-way.

Second, interactive mode

When you accept user directives, MVC can be divided into two different ways. One is to accept the instruction through the View and pass it to Controller.


The other is to accept instructions directly through controller.


Iii. Example: Backbone

Practical projects tend to adopt a more flexible approach, taking backbone.js as an example.


1. The user can send instructions to the view (DOM event), and then the view directly requires Model to change the state.

2. Users can also send instructions directly to Controller (change URL trigger Hashchange event), and then sent to View by Controller.

3. Controller is very thin, only play the role of routing, and view is very thick, business logic is deployed in view. So, backbone simply cancels the Controller, leaving only one Router (router).

Four, MVP

The MVP model renamed Controller the presenter and changed the direction of communication.


1. Communication between the parts is two-way.

2. View and Model do not occur in contact, are passed through the presenter.

3. View is very thin, do not deploy any business logic, called "Passive View" (passive view), that is, there is no initiative, and presenter is very thick, all the logic is deployed there.

Five, MVVM

The MVVM model presenter renamed ViewModel, which is basically the same as the MVP model.


The only difference is that it uses bidirectional bindings (data-binding): View changes are automatically reflected in ViewModel, and vice versa. Both angular and ember adopt this pattern.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.