What are MVC, MVP, and MVVM respectively _ dynamic node Java school arrangement, mvcmvvm

Source: Internet
Author: User

What are MVC, MVP, and MVVM respectively _ dynamic node Java school arrangement, mvcmvvm

I. MVC

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

View: user interface.

Controller: business logic

Model: Data Storage

The communication methods between different parts are as follows.

1. View sends commands to the Controller

2. After the Controller completes the business logic, the Model is required to change the status.

3. The Model sends new data to the View. The user gets feedback.

All communications are unidirectional.

Ii. Interaction Mode

When receiving user instructions, MVC can be divided into two methods. One is to pass commands to the Controller through View.

The other is to directly receive commands through the controller.

Iii. Example: Backbone

Actual projects often adopt a more flexible approach, taking Backbone. js as an example.

1. You can send a command (DOM Event) to the View, and the View directly requires the Model to change the state.

2. You can also send commands directly to the Controller (the hashChange event is triggered when the URL is changed), and then the Controller sends the command to the View.

3. The Controller is very thin and only serves as a route. The View is very thick and the business logic is deployed in the View. Therefore, the Backbone simply cancels the Controller and retains only one Router ).

Iv. MVP

In MVP mode, the Controller is renamed as Presenter, and the communication direction is changed.

1. Communication between all parts is bidirectional.

2. View and Model are transmitted through Presenter.

3. The View is very thin and does not deploy any business logic. It is called the Passive View, that is, there is no initiative, and the Presenter is very thick. All the logic is deployed there.

V. MVVM

In MVVM mode, the Presenter is renamed as ViewModel, basically consistent with the MVP mode.

The only difference is that it uses data-binding: View changes, automatically reflected in ViewModel, and vice versa. Angular and ember both adopt this mode.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

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.