Thursday, April 30, 2009

WPF and MVVM - Intro

It's been over a month since I made my initial entry. Since that time I've begun a new project at Hewlett-Packard. Out team is working on a WPF application and will be attempting to use the Model-View-ViewModel (M-V-VM) pattern, since we've heard that WPF was designed with that pattern in mind. None of us know much about either right now. I've decided to describe my learnng experience. Hopefully my experience will help you and save you some of the growing pains that I will probably experience.

My wife has been after me for quite some time to keep better track of our investments. That's a pretty good idea actually. So, I'm going to learn by developing an Investment Tracking application. For those of you who decide to follow along, feel free to chime in with some suggestions.

Let's start by looking at M-V-VM itself. My understanding is that it is an offshoot of the Model-View-Controller pattern. The 'M', or Model, describes the business which your application is supporting, and is comprised of a related set of classes traditionally called business objects in a standard 3-tier application. The 'V', or View, is the UI - the portion of the application where the user interacts with your application and its data. The 'VM', or View Model, sits in between the View and the Model. It models the data displayed in the UI, which might not exactly correspond to the business objects of the Model. It also controls all the behaviors which the View must support. Thus the View is "dumb", and the View Model contains all the requisite "smarts." None of these layers directly address data access, so really, the way I understand the situation, you end up with having at least a 4-tiered application.

One of the selling points of M-V-VM is supposed to be the ability to apply unit tests to much more of the application - specifically to the Model, View Model, and Data Access tiers. We're going to find out, folks!

With all of this in mind, the first step is to set up the solution with a starting set of projects. They should be fairly self-explanatory:




No comments:

Post a Comment