Model-View-ViewModel (MVVM)

KnockoutJS is based on MVVM pattern. It is an architectural pattern used to design software applications. John Gossman, a Microsoft architect, built the model in 2005. The biggest benefit of the model is that it separates the business logic from graphical user interface. Derived from ViewModel Controller Pattern, this very model makes it very easy to manage and represent data by allowing you to handle underlying data in a certain way. You can also represent abstract forms of actions and View’s state via ViewModel in Model-View-ViewModel.

The ViewModel and Model classes do not know that the view classes exist and the vice versa. Similarly, Model has no idea that both the View and ViewModel exist.

View:

View is usually created through a markup language. It is actually a Graphical User Interface which helps you represent data. It works on the principle of data binding to connect properties of a ViewModel. The data bind concept itself is indirectly connected to model data. If there is any change in a ViewModel, you need to change the View as well. The binding automatically reflects all the changes made in ViewModel in View.

Model:

It is simply a business object or domain data. It is the Model which actually holds all the real time data. However, it has nothing to do with behaviors. They are mostly implemented in business logic layer.

ViewModel:

ViewModel is the main processing unit of the MVVM and holds dynamic data. Data from both View and Model integrates at ViewModel through an implicit binder which makes them communicate with each other. This binder contains command binding and declarative data. The binder is also responsible for synchronizing ViewModel and View. Changes occurring in both the View and ViewModel reflect in each other. The existence of automatic 2 way binding is the most important aspect of this model.

Copyright 2005-2016 KnowledgeHills. Privacy Policy. Contact .