- Your code is easier to understand, maintain and troubleshoot.
- You are much more productive when you leverage the frameworks’ (WPF, Silverlight, XAML, WinRT) built-in features like Data Binding, Resource Dictionaries, Dependency Properties, Routed Events, Commands, etc.
- You can test your app’s behavior “under-the-skin,” avoiding the pitfalls and cost of testing at the UI level.
- Your ViewModels afford testability. You can have unit test coverage allowing “Test-Driven-Development” and “Automated Regressions.”
- Decoupling the View from the ViewModel in the way enabled by MVVM allows designers and developers to work productively in harmony.
Model-View-ViewModel (MVVM) is a client-side design pattern. It guides the structure and design of your code to help you achieve “Separation of Concerns.” Implementing MVVM requires a bit of a mind-shift in the way you think about the functionality of your application. It has a significant learning curve and requires some additional upfront effort to get started on the right path. But the benefits are significant:
CensusMapper is a Windows 8 app that retrieves U.S. Census Data using the recently released Census API and displays that data on a map using Microsoft’s Bing Maps API. The application is built using XAML and C#. The intent of this version is to establish a proof of concept as well as introduce a design and user-experience direction to be explored and evolved going forward.
Upon startup, the app retrieves the population counts for each U.S. State and displays those counts in a marker positioned in the geographic middle of each state.