The difference between MVC and MVVC

一、MVC (Model-View-Controller)

Definition: Model-View-Controller is a software design pattern that separates business logic, data, and interface display, and is more biased toward the back end.
Purpose: Separate model and view code so that the same program can achieve different presentation methods.
Insert image description here

MVC programming pattern

MVC is a pattern for creating Web applications using MVC (Model View Controller model-view-controller) design:
Model represents the core of the application (such as a database).
View display effect (HTML page).
Controller handles input (business logic).

The MVC pattern provides complete control over HTML, CSS, and JavaScript at the same time.
A model is the part of an application that handles the logic of the application's data.
  Typically model objects are responsible for accessing data in the database.
View is the part of the application that handles the display of data.
  Typically views are created from model data.
A Controller is the part of an application that handles user interaction.
  Typically the controller is responsible for reading data from the view, controlling user input, and sending data to the model.

二、MVVC(Model-View-ViewModel)

MVVM is the abbreviation of Model-View-ViewModel. That is model-view-viewmodel.
Model refers to the data passed by the backend.
View refers to the page you see.
The view model (ViewModel) is the core of the mvvm mode. It is the bridge connecting the view and the model.
It has two directions:
one is to convert the model (Model) into a view (View), that is, convert the data passed by the backend into the page you see. The way to achieve this is: data binding.
The second is to convert the view into a model, that is, convert the page you see into back-end data. The way to implement it is: DOM event listening.
Implementing both directions is called two-way binding of data.

Components of the MVVM pattern

Model
Model refers to the domain model that represents the content of the real state (object-oriented), or to the data access layer that represents the content (data-centric).

View
Just like in MVC and MVP patterns, the view is the structure, layout and appearance (UI) that the user sees on the screen.

View Model
A view model is an abstraction of a view that exposes public properties and commands. MVVM does not have an MVC mode controller, nor an MVP mode presenter, but a binder. In a view model, binders communicate between the view and the data binder.

Binders
Declarative data and command bindings are implicit in the MVVM pattern. In the Microsoft solution stack, the binder is a markup language called XAML. Binders save developers from being forced to write boilerplate logic to synchronize view models and views. The emergence of declarative data binding technology was a key factor in enabling this pattern when implemented outside of Microsoft's heap.

The difference between MVVM framework and MVC framework

There is actually not much difference between mvc and mvvm. They are both design ideas. The main differences are as follows:

1.Controller in mvc evolves into viewModel in mvvm

2.mvvm drives the display of the view layer through data rather than node operations.

3. Model and View in MVC can interact directly, resulting in a high degree of coupling between the Model layer and the View layer. In mvvm, Model and View do not interact directly, but are synchronized through the intermediate bridge ViewModel.

4.mvvm mainly solves the problem: A large number of DOM operations in mvc reduce page rendering performance, slow down loading speed, and affect user experience.

Guess you like

Origin blog.csdn.net/qq_52654932/article/details/130514964