Thursday, July 16, 2015

What is Model-View-ViewModel Pattern?

MVVM (Model-View-ViewModel) pattern is an extension of the MVC pattern, the MVVM pattern adds another layer called ViewModel which is a model representation more in sync with the view, the controls in the view are bound to the properties in the ViewModel and any event which is raised from the View are handled by commands in the view model.

The properties in the ViewModel are bound to the view objects, any changes made to the properties in the ViewModel will get automatically reflected in the View.

The View layer is totally isolated from the Model, the ViewModel interacts with the model and transforms the model objects in such a way that is binds with the view.

The MVVM Pattern come in handy when we want to have different views for the same model and business logic, for example if we need a windows client and a web client UI to display the same information in a different way, then we can have a common Model and Business class layer, with each of the client UI’s having its own ViewModel, this way changes in the UI between the 2 client applications will not affect the Model or business classes, the ViewModel takes care of transforming the models to suite the appropriate views.




Search Flipkart Products:
Flipkart.com

No comments: