To follow me in this post I believe you need to have some pre knowledge about this Model/View/ ViewModel-pattern.
In my company we have a thing called "fagkveld". Its basically 1,5 hours where we present different design patterns and best practices to each other. To night Kjetil talked about something that I think is really exiting; the pattern Model View ViewModel. It's a pattern, among other things, for separating the (business) logic from the GUI (in Windows Presentation Foundation).
I have implemented the Model View Controller pattern in WPF earlier, and didn't then see the advantage of using a ViewModel. To night I understood what you gain using a ViewModel.
When using ViewModel on top of a (domain) model you get the benefit of customizing the ViewModel to exactly fit your views needs. If you need to change the data before you present it in the view, you can do this in the ViewModel. Let's say you have a model representing a person and you want to merge the persons first name and last name into one textbox in the view. You can do this in the ViewModel to avoid adding logic to the code behind file in the view. To completely remove code from the view, you also can use the Routed command pattern included in WPF. If you have a (domain) model that isn't suitable to databind to your view, ViewModel is your savior.
A problem I see using a ViewModel, is that the (domain) model isn't updated before you specific tell it to update it self. If other parts of the application relies on the model being updated "on the fly", you may have a problem. But, i guess this problem is possible to overcome.
Model View ViewModel is perfect to adapt an "old" domain model to support the mind blowing features in Windows Presentation Foundation.
Good reading for learning about the pattern:
http://blogs.msdn.com/johngossman/archive/2005/10/08/478683.aspx
Tags: