MVC, MVP and MVVM are proposed to solve practical problems in the development process, and are widely used as several mainstream architectural patterns.

A, the MVC

MVC is an intuitive architectural pattern, which is mainly divided into the following three parts:

- Model: data save View: user interface - Controller: service logicCopy the code

Its operation process is: user operations ->View (responsible for receiving user input operations) ->Controller (business logic processing) ->Model (data persistence) ->View (feedback results to View). All communication in MVC is one-way.

Second, the MVP

MVP mode changes the name of Controller to Presenter and changes the direction of communication. It cuts the link between the View and the Model, and the Presenter acts as a bridge, so that the communication between the View and the Model is completely isolated, while the communication between the other parts is two-way.

Third, MVVM

The MVVM mode changes the Presenter name to ViewModel, essentially identical to the MVP mode. It takes the idea of “two-way binding of data Model data” as the core, so there is no connection between View and Model, and the interaction between Model and ViewModel is two-way, so the change of View data will modify the data source at the same time. Changes in the data source are immediately reflected in the View.

While the traditional front end would manually render data to the page, the MVVM mode does not require the user to receive manipulation DOM elements. Binding the data to the viewModel layer automatically renders the data to the page, and notifies the viewModel layer to update the data when the view changes.

The difference between:

In the case of MVP and MVC, the View does not directly use the Model in THE MVP. Communication between the View and the Model is carried out through the Presenter (Controller in MVC). All interaction takes place within the Presenter. In MVC, the View reads data directly from the Model instead of through the Controller.

The only difference between MVVM and MVP is that MVVM uses data-binding: Changes to the View are automatically reflected in the ViewModel.