Introduction to MVVM

Introduction and History

The Model View ViewModel (MVVM) is an architectural pattern used in software engineering that originated from Microsoft as a specialization of the presentation model design pattern introduced by Martin Fowler.1 Largely based on the model–view–controller pattern (MVC), MVVM is targeted at modern UI development platforms which support Event-driven programming, such as HTML5,23 Windows Presentation Foundation (WPF), Silverlight and the ZK framework.

MVVM facilitates a clear separation of the development of the graphical user interface (either as markup language or GUI code) from the development of the business logic or back end logic known as the model (also known as the data model to distinguish it from the view model). The view model of MVVM is a value converter4 meaning that the view model is responsible for exposing the data objects from the model in such a way that those objects are easily managed and consumed. In this respect, the view model is more model than view, and handles most if not all of the view’s display logic (though the demarcation between what functions are handled by which layer is a subject of ongoing discussion5 and exploration). The view model may also implement a mediator pattern organising access to the backend logic around the set of use cases supported by the view.

MVVM was designed to make use of data binding functions in WPF to better facilitate the separation of view layer development from the rest of the pattern by removing virtually all GUI code (“code-behind”) from the view layer.6 Instead of requiring user interface (UXi) developers to write GUI code, they can use the framework markup language (e.g., XAML) and create bindings to the view model, which is written and maintained by application developers. This separation of roles allows interactive designers to focus on UX needs rather than programming or business logic, allowing for the layers of an application to be developed in multiple work streams for higher productivity. Even when a single developer works on the entire code base a proper separation of the view from the model is more productive as the user interface typically changes frequently and late in the development cycle based on end-user feedback.

Source: Wikipedia


MVVM was originaly created by Microsoft as a successor of MVC for alive interfaces.
Indeed, MVC was designed to serve a request/response scheme. Controller inject Model in a View and return the view. After his execution, there is no link between view and controller.

MVVM display a View which is bound to a ViewModel. Then when ViewModel properties changed, view is automatically updated. MVVM is prefered to MVC in scenarios where we have an alive interface.

HTML5 and new Javascript APIs allow creation of full working in-browser apps. So MVVM can be a way to apply great app pattern to HTML5.

Last edited Dec 20, 2012 at 5:59 PM by SomaticIT, version 1


No comments yet.