Geeks With Blogs

News Locations of visitors to this page

Brian Genisio's House of Bilz

More Adventures in MVVM Shout it kick it on

imageA demo that I added to my MVVM talk is one that compares a “Ball of Mud” application with a componentized MVVM application with the exact same set of features.  I do this to contrast a messy, un-testable work of code to a cleanly separated, testable work.  The application I chose to write is a Twitter search application in WPF.  When you download the code, you will see two folders: “BallOfMud” and “MVVM”. 

The “Ball of Mud” app includes the entire app in a XAML file and a code-behind.  The code is incredibly dense… it does a TON of stuff, all in one page of code.  Unfortunately, is practically un-testable.  Even if you could test it, the code hits a live  Not the way you want to write tests.  This way of writing software works well for demos, but it certainly does not scale to real-life applications.

The MVVM example, on the other hand, is significantly broken up into components (4 layers).  There are 2 Views (TwitterSearchView and TweetView) with 2 corresponding ViewModels.  Then, there is a Model layer which is responsible for parsing data that comes from the Service layer into “Tweets”.  There is more code than the “Ball of Mud” example, but the code is testable, and modular.  You can swap out different services or models, if you wish.  In fact, in the Model layer, you will find a “CannedData” class that I use when I don’t have an internet connection when I give my presentation.  It just swaps in.  This example might feel like “overkill”, but as the application grows in scope, this architecture will scale exceptionally well.

Twitter Search “Ball of Mud” vs “MVVM”

Posted on Friday, June 19, 2009 9:32 PM | Back to top

Comments on this post: Adventures in MVVM -- Ball of Mud vs MVVM

# re: Adventures in MVVM -- Ball of Mud vs MVVM
Requesting Gravatar...
Nice sample
While you are on your adventures, would you mind posting something about using dialogs in MVVM and where they fit into the whole architecture?
Left by Lukas Domagala on Jun 21, 2009 11:39 PM

# re: Adventures in MVVM -- Ball of Mud vs MVVM
Requesting Gravatar...
@Lukas - There's a small discussion over at

Hope this helps.
Left by Jason Jarrett on Jun 22, 2009 7:38 AM

# re: Adventures in MVVM -- Ball of Mud vs MVVM
Requesting Gravatar...
Last week was my first presentation while playing the Solution Architect Role in ArabiaGIS, so I tried to start with an introduction to design patterns, and my first subject was the Model-View-ViewModel design pattern. in the presentation I tried to introduce the design pattern concept, showing its importance and the goals off applying it.

The presentation will focus on the history and the importance of MVVM and then go into the detailed of this important design pattern for architecting a WPF application.

To see the presentation:
Left by Hasan Jaffal on Nov 15, 2009 7:53 PM

Your comment:
 (will show your gravatar)

Copyright © Brian Genisio's House Of Bilz | Powered by: