Rockford Lhotka's Blog

Home | | CSLA .NET

 Monday, May 07, 2012
« Should I learn Silverlight? Objective C?... | Main | Set rich text into RichTextBlock control... »

There are three fairly popular presentation layer design patterns that I collectively call the “M” patterns: MVC, MVP, and MVVM. This is because they all have an “M” standing for “Model”, plus some other constructs.

The thing with all of these “M” patterns is that for typical developers the patterns are useless without a framework. Using the patterns without a framework almost always leads to confusion, complication, high costs, frustration, and ultimately despair.

These are just patterns after all, not implementations. And they are big, complex patterns that include quite a few concepts that must work together correctly to enable success.

You can’t sew a fancy dress just because you have a pattern. You need appropriate tools, knowledge, and experience. The same is true with these complex “M” patterns.

And if you want to repeat the process of sewing a fancy dress over and over again (efficiently), you need specialized tooling for this purpose. In software terms this is a framework.

Trying to do something like MVVM without a framework is a huge amount of work. Tons of duplicate code, reinventing the wheel, and retraining people to think differently.

At least with a framework you avoid the duplicate code and hopefully don’t have to reinvent the wheel – allowing you to focus on retraining people. The retraining part is generally unavoidable, but a framework provides plumbing code and structure, making the process easier.

You might ask yourself why the MVC pattern only became popular in ASP.NET a few short years ago. The pattern has existed since (at least) the mid-1990’s, and yet few people used it, and even fewer used it successfully. This includes people on other platforms too, at least up to the point that those platforms included well-implemented MVC frameworks.

Strangely, MVC only started to become mainstream in the Microsoft world when ASP.NET MVC showed up. This is a comprehensive framework with tooling integrated into Visual Studio. As a result. typical developers can just build models, views, and controllers. Prior to that point they also had to build everything the MVC framework does – which is a lot of code. And not just a lot of code, but code that has absolutely nothing to do with business value, and only relates to implementation of the pattern itself.

We’re in the same situation today with MVVM in WPF, Silverlight, Windows Phone, and Windows Runtime (WinRT in Windows 8). If you want to do MVVM without a framework, you will have to build everything a framework would do – which is a lot of code that provides absolutely no direct business value.

Typical developers really do want to focus on building models, views, and viewmodels. They don’t want to have to build weak reference based event routers, navigation models, view abstractions, and all the other things a framework must do. In fact, most developers probably can’t build those things, because they aren’t platform/framework wonks. It takes a special kind of passion (or craziness) to learn the deep, highly specialized techniques and tricks necessary to build a framework like this.

What I really wish would happen, is for Microsoft to build an MVVM framework comparable to ASP.NET MVC. Embed it into the .NET/XAML support for WinRT/Metro, and include tooling in VS so we can right-click and add views and viewmodels. Ideally this would be an open, iterative process like ASP.NET MVC has been – so after a few years the framework reflects the smartest thoughts from Microsoft and from the community at large.

In the meantime, Caliburn Micro appears to be the best MVVM framework out there – certainly the most widely used. Probably followed by various implementations using PRISM, and then MVVM Light, and some others.

Monday, May 07, 2012 3:11:10 PM (Central Standard Time, UTC-06:00)
I think knockout.js should be up there in the list of "best MVVM frameworks" because it does an amazing job for client side web programming.
Monday, May 07, 2012 3:25:07 PM (Central Standard Time, UTC-06:00)
I think you're mostly right...but I think that understanding the pattern is more important than the pattern. I used to do a MVVM talk where I built most everything by hand so people could see the moving parts...which makes picking a framework much easier. Unfortunately, in many shops someone picks the framework based on the popularity; not the fit to the development project.

For me the frameworks tend to be recommended in this order:

- MVVM Light: Requires the least 'do it my way' than the other two listed here. Small and consise which has great merits.
- Caliburn Micro: Most complete but more complex for simple scenarios. Probably not a candiate for smallish projects IMO (e.g. mobile)
- Prism: Good disconnected framework and if you're trying to interoperate or be complete a "Built-by-MS", this is a good strategy. Good interop with EntLib and other PnP projects. But not my first choice.

(Almost wrote my own post, but thought this was easier ;)
Monday, May 07, 2012 11:38:13 PM (Central Standard Time, UTC-06:00)
If you're interested in something similar to ASP.NET MVC for WPF apps I think that Magellan might be of interest to you.
Aidan Morgan
Tuesday, May 08, 2012 5:51:01 AM (Central Standard Time, UTC-06:00)
Nice article! I agree with this for new project.

What im struggling with, is that the project im working on has been around since silverlight 1.
There has been alot of different developers over time and the codebase is messy, to say the least.

Rewriting is not an option. What i do is to gradually replace parts. Whenever there is a component that needs rework, i rewrite it using only the very very basic of mvvm. Bringing in a full framwork wont really help me at this point. What i hope and strive for it to get the management to "see the light" and be currious on the reasons behind big increases in productivity. I'm a consultat with about 6 months on the project now.

But yes, i wouldnt try to build myself an event router but i do believe in small baby steps starting small, bring in mvvm piece by piece with lots of legacy code.

Any thought on that?
Tuesday, May 08, 2012 4:42:45 PM (Central Standard Time, UTC-06:00)
yet another reason to ditch XAML in favor ASP.NET MVC!

just kidding... sorry i could not help myself
Wednesday, May 09, 2012 10:27:56 AM (Central Standard Time, UTC-06:00)
I was very surprised you endorsed Caliburn as the "best". Perhaps best for you? In my experience there's no way I would make that recommendation about *any* MVVM framework because they are all so different and there is *no* objectively "best" framework. I chose Prism after thoroughly examining every MVVM framework out there I could get info on including Caliburn.

Some are more thorough than others and support more features but often they might be features you don't need so it's not that easy.
Thursday, May 10, 2012 1:25:45 PM (Central Standard Time, UTC-06:00)
Have you ever tried the Catel MVVM Framework?
I find it surprisingly easy and feature rich.
Until now I used Bxf for my spike solutions.
After migrating to Catel, the only thing I am curious about is which ViewModelBase class I should use.
The one contained within Catel works perfectly with Catel (how surprising!).
But the one from Csla.Xaml features the Csla specific methods like BeginRefresh or the CanXyz methods and the builtin model property...
Maybe I should derive a class from Catel.ViewModelBase and reinvent the features from Csla.Xaml.ViewModelBase<T> ?
Any suggestions?
Alexander Becker
Monday, May 14, 2012 1:29:21 PM (Central Standard Time, UTC-06:00)

I'm certain you have enough plates spinning at any one time, but will Bxf receive any further attention? I find it to be a nice lightweight MVVM framework that I use as a base while developing my business,data layer and view models. At a more advanced stage I replace that project with Prism, but Bxf is so much lighter/easier to do initial dev with.

Ed Mathias
Monday, May 28, 2012 11:58:08 AM (Central Standard Time, UTC-06:00)
Based purely on number of downloads, I believe that MVVM Light (disclaimer: this is my framework ;) is more widely used than Caliburn.Micro. I recently celebrated 120'000 downloads from Codeplex and Nuget.

That said there are no doubts that Caliburn is an excellent framework too.

Comments are closed.
On this page....
Feed your aggregator (RSS 2.0)
February, 2016 (3)
January, 2016 (4)
December, 2015 (4)
November, 2015 (2)
October, 2015 (2)
September, 2015 (3)
August, 2015 (3)
July, 2015 (2)
June, 2015 (2)
May, 2015 (1)
February, 2015 (1)
January, 2015 (1)
October, 2014 (1)
August, 2014 (2)
July, 2014 (3)
June, 2014 (4)
May, 2014 (2)
April, 2014 (6)
March, 2014 (4)
February, 2014 (4)
January, 2014 (2)
December, 2013 (3)
October, 2013 (3)
August, 2013 (5)
July, 2013 (2)
May, 2013 (3)
April, 2013 (2)
March, 2013 (3)
February, 2013 (7)
January, 2013 (4)
December, 2012 (3)
November, 2012 (3)
October, 2012 (7)
September, 2012 (1)
August, 2012 (4)
July, 2012 (3)
June, 2012 (5)
May, 2012 (4)
April, 2012 (6)
March, 2012 (10)
February, 2012 (2)
January, 2012 (2)
December, 2011 (4)
November, 2011 (6)
October, 2011 (14)
September, 2011 (5)
August, 2011 (3)
June, 2011 (2)
May, 2011 (1)
April, 2011 (3)
March, 2011 (6)
February, 2011 (3)
January, 2011 (6)
December, 2010 (3)
November, 2010 (8)
October, 2010 (6)
September, 2010 (6)
August, 2010 (7)
July, 2010 (8)
June, 2010 (6)
May, 2010 (8)
April, 2010 (13)
March, 2010 (7)
February, 2010 (5)
January, 2010 (9)
December, 2009 (6)
November, 2009 (8)
October, 2009 (11)
September, 2009 (5)
August, 2009 (5)
July, 2009 (10)
June, 2009 (5)
May, 2009 (7)
April, 2009 (7)
March, 2009 (11)
February, 2009 (6)
January, 2009 (9)
December, 2008 (5)
November, 2008 (4)
October, 2008 (7)
September, 2008 (8)
August, 2008 (11)
July, 2008 (11)
June, 2008 (10)
May, 2008 (6)
April, 2008 (8)
March, 2008 (9)
February, 2008 (6)
January, 2008 (6)
December, 2007 (6)
November, 2007 (9)
October, 2007 (7)
September, 2007 (5)
August, 2007 (8)
July, 2007 (6)
June, 2007 (8)
May, 2007 (7)
April, 2007 (9)
March, 2007 (8)
February, 2007 (5)
January, 2007 (9)
December, 2006 (4)
November, 2006 (3)
October, 2006 (4)
September, 2006 (9)
August, 2006 (4)
July, 2006 (9)
June, 2006 (4)
May, 2006 (10)
April, 2006 (4)
March, 2006 (11)
February, 2006 (3)
January, 2006 (13)
December, 2005 (6)
November, 2005 (7)
October, 2005 (4)
September, 2005 (9)
August, 2005 (6)
July, 2005 (7)
June, 2005 (5)
May, 2005 (4)
April, 2005 (7)
March, 2005 (16)
February, 2005 (17)
January, 2005 (17)
December, 2004 (13)
November, 2004 (7)
October, 2004 (14)
September, 2004 (11)
August, 2004 (7)
July, 2004 (3)
June, 2004 (6)
May, 2004 (3)
April, 2004 (2)
March, 2004 (1)
February, 2004 (5)

Powered by: newtelligence dasBlog 2.0.7226.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2016, Marimer LLC

Send mail to the author(s) E-mail

Sign In