Brian Genisio's House of Bilz

  Home  |   Contact  |   Syndication    |   Login
  62 Posts | 0 Stories | 118 Comments | 0 Trackbacks

News

Locations of visitors to this page

Archives

Post Categories

Who am I?

More Adventures in MVVM Shout it kick it on DotNetKicks.com

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 twitter.com.  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

Feedback

# re: Adventures in MVVM -- Ball of Mud vs MVVM 6/21/2009 11:39 PM Lukas Domagala
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?
thanks

# re: Adventures in MVVM -- Ball of Mud vs MVVM 6/22/2009 7:38 AM Jason Jarrett
@Lukas - There's a small discussion over at http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=46353

Hope this helps.

# re: Adventures in MVVM -- Ball of Mud vs MVVM 11/15/2009 7:53 PM Hasan Jaffal
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: http://solutionsarchitecture.wordpress.com/2009/11/13/introduction-about-mvvm-model-view-viewmodel-design-pattern/

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: