"Go" web front-end development: Why MVVM is chosen instead of MVC

Source: Internet
Author: User

The web is flooded with so-called MVC frameworks, and it seems to me that, for some critical technical reasons, MVC is simply not available at all in Web front-end development (right, not, not wrong)

The web is flooded with so-called MVC frameworks, and it seems to me that, for some critical technical reasons, MVC is simply not available at all in Web front-end development (right, not, not wrong).

In the MVC original report, it was noted that:

View will never know the user input, such as mouse actions and keystrokes.

Obviously, in the Web front end, you can't do this because in a Web program, the user's input must be obtained by listening to events on Windows, documents, and elements. -and these things are often considered to be view.

So some strange realizations were born, such as that the controller should be the intermediary of the view operation model.

I've tried to design a programming model to let all the events flow through the controller, but in fact I find it very bad. --This attempt has shifted me from MVC to MVVM.

John Gossman (the architect of WPF) mentions in his article that

The View in Model/view/viewmodel represents a more complex control in a visible element, a button, a form, a graphic, or a GUI that encodes a shortcut key, and the control itself manages the interaction with the input device- This is supposed to be the controller's responsibility in MVC (the thing that happens to a controller in a modern GUI environment is a long digression ...). I tend to think it's just hidden behind the scenes, it's still there, but we don't have to think about it as much as 1979.

The correctness of a structure like MVC is that any interface needs to face a user, and the controller "is a link between the user and the system." In classic MVC, most of what the controller does is to distribute the user input to different view, and to get the editor from view when necessary to change the model, and the web and most of the current UI systems, The controller's responsibilities have been implemented by the system. The following picture illustrates the evolution of this process:

In summary, for MVC

    • Designed for 1979 years of Smalltalk
    • Both the interface and the program are written in the same language
    • User input is handled entirely by the program writer
    • View is purely for display

For MVVM

    • Designed for 2005 years of WPF
    • The interface uses markup language more, and the program uses the programming language
    • User input is processed and distributed through the UI system, most of which is known by the user program in the form of events
    • View is independent, able to manage partial user input and react on its own (they are often referred to as controls rather than views)

As a web developer, it is obvious what choice to make between the two.

"Go" web front-end development: Why MVVM is chosen instead of MVC

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.