Friday, March 25, 2011

Model-View-ViewModel (MVVM) Pattern


Advantage of this pattern of separation is the functional development provided by MVC as well as using the advantages of XAML by binding data while using it. ViewModel, and any Business Layer’s inherent data checking features to validate any incoming data. The result is that the Model and Foundation drive as much of the operations as possible, minimizing the need for “code behind” especially in the View.
Model: as in the classic MVC / MVP pattern, the model refers to either  an object model that represents the real state content or the data access layer that represents that content (a data-centric approach).
View: as in the classic MVC / MVP pattern, the view refers to all elements displayed by the GUI such as buttons, windows, graphics, and other controls.
ViewModel: the ViewModel is a “Model of the View” meaning it is an abstraction of the View that also serves in data binding between the View and the Model. It could be seen as a specialized aspect of what would be a Controller that acts as a data binder/converter that changes Model information into View information and passes commands from the View into the Model. The ViewModel exposes public properties, commands, and abstractions. The ViewModel has been likened to a conceptual state of the data as opposed to the real state of the data in the Model.
This implementation/pattern wildly used in Silverlight application development. 

No comments: