This is a mirror of official site: http://jasper-net.blogspot.com/

MVVM Technical Description

| Monday, November 15, 2010
The gold standard for learning and describing design patterns is the book, Design Patterns: Elements of Reusable Object-Oriented Software.

Below, I present the MVVM pattern using the chapter format, section titles defined in the book.

Model-View-ViewModel

UI Design

Intent
Provide a clean separation of concerns between the user interface controls and their logic.

Also Known As
MVVM, M-V-VM and ViewModel

Motivation
Development languages like Visual Basic (1-6), Microsoft Access, .NET Windows Forms, WPF, Silverlight and Windows Phone 7 provide a default experience that leads a developer down the path of dragging controls from a Toolbox to a design surface then writing code in the form's code-behind file. Many software companies and consultants have successfully delivered applications authored using these languages to customers.

As these applications grew in size and scope and were modified over-time, complex maintenance issues began to surface. Some of these issues were limitations of the language; others resulted from the lack of supporting infrastructure like source control or test frameworks. Some were the result of application logic being located in code-behind files and the resulting tight coupling between the UI form controls and the code-behind that increased the cost to make form modifications.

The four top reasons for using the MVVM pattern in Microsoft XAML applications are:

  • Provides separation of concerns
  • It is natural pattern for XAML platforms
  • Enables the developer-designer workflow
  • Increases application testability

Customer Maintenance Form Scenario
Let's quickly examine a common scenario found in forms over data applications and see how the MVVM pattern is used.

Our application requires a data entry form that allows a customer entity to be displayed, saved and or deleted.

The MVVM pattern addresses separation of concerns by defining that UI application logic be located in a view model class as opposed to the view's code-behind file. It leverages the rich data binding stack of the XAML platform to expose the view model to the view's UI controls through the view's DataContext property. A by-product of the separation of concerns is the enablement of a clean developer-designer workflow. Designers are now emancipated to modify the UI, change or rename controls to suite their requirements without breaking the application. Application testability has been increased because the view model takes its dependencies in the form interfaces, allowing the view model to be individually tested in isolation.

Read more: .NET Developer Guidance

Posted via email from .NET Info

0 comments: