What is the difference between mvc and mvvm ?, What is the difference between mvcmvvm?

Source: Internet
Author: User

What is the difference between mvc and mvvm ?, What is the difference between mvcmvvm?

Source: https://segmentfault.com/q/1010000000534091? _ Ea = 178721

 

Model: Very simple, it is the data objects related to the business logic, which are usually mapped from the database. We can say thatModel corresponding to the database.

View: It is also very simple, that is, the displayed user interface.

Basically, most software simply reads data from data storage, presents the data to the user interface, receives input from the user interface, and writes it to the data storage. Therefore, there is almost no objection to the two layers of data storage (model) and interface (view. However, different people have different opinions on how to present the model to the view and how to write data from the view to the model.

In MVC's opinion, every change on the interface is an event. I only need to write a bunch of code for each event, to convert user input into objects in the model. This heap of code can be called controller.

In MVVM's opinion, I defined a corresponding data object for various controls in the view, so that as long as the data object is modified, the content displayed in the view will be automatically refreshed, in view, the data object is automatically updated after any operation. Therefore:

ViewModel: YesModel corresponding to the interface (view). Because the database structure often cannot correspond to interface controls one by one directly, you need to define a data object to correspond to the controls on The view. ViewModel encapsulates the model object into interface data objects that can display and accept input.

As for the viewmodel data, as the view is automatically refreshed and synchronized to the model, this part of the code can be written as a public framework, so you don't have to worry about it yourself.

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.