Jeremy D. Miller -- The Shade Tree Developer

Sponsors

The Lounge

Wicked Cool Jobs

Syndication

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
The Build Your Own CAB Series Table of Contents

Yes, this is overdue.  Here is an introduction and table of contents to my "Build Your Own CAB" series of blog posts on designing WinForms applications.  You'll see nothing here about user experience and not much WinForms technology.  That stuff is covered quite well in a hundred different places.  This series is about code.  How to write it, how to write less, how to test it, and how to structure it.  And there is code in user interfaces, no doubt about that.  Code that's complex.  Code that changes every time you're foolish enough to ask an end user how they like it.  Code that's hard to test if you're not careful.

I'm still working on the series, so check back here occasionally for updates and new downloads.  After I finish posting the menu state series I'm going to take a break for a while, but it's for a good cause.  The most persistent complaint throughout the series is that it's not clear how all the pieces fit together.  Understandable.  At the same time that I'm writing this series I'm also working on my OSS StoryTeller tool that includes a sizable WinForms client.  Last week I scrapped about half of the StoryTeller UI code so I could go back and incorporate the ideas that I've explored through "Build a CAB."  I can say without a doubt that I'm the one person who's learned the most from "Build a CAB."  What I'm hoping to do is use the StoryTeller UI code to demonstrate fully working screens from end to end.  The beauty of using OSS code for examples is that the code is automatically available for download.

I'll finish before the end of the summer, I promise.  Just set a bookmark to this page and I'll keep updating it as the series expands.  At the end I've committed to gathering all this stuff up into a single, printable PDF for download.
 

 

Downloads

Soon...

 

Table of Contents

There's an extended introduction below.

  1. How I got into this mess - Look for the section "Microsoft, OSS, and the Patterns and Practices Team"
  2. Preamble
  3. The Humble Dialog Box
  4. Supervising Controller
  5. Passive View
  6. Presentation Model
  7. View to Presenter Communication
  8. Answering some questions
  9. What's the Model?
  10. Assigning Responsibilities in a Model View Presenter Architecture
  11. Domain Centric Validation with the Notification Pattern
  12. Unit Testing the UI with NUnitForms
  13. Event Aggregator
    1. Event Aggregator with Generics
  14. Rein in runaway events with the "Latch"
  15. Embedded Controllers with a Dash of DSL
  16. Managing Menu State with MicroController's, Command's, a Layer SuperType, some StructureMap Pixie Dust, and a Dollop of Fluent Interface
    1. MicroControllers
    2. Boil down the "wiring" to a Registry
    3. The Command Executor
    4. The Main Players
    5. Testing through the UI - Forthcoming
    6. Subcutaneous Testing - Forthcoming
    7. Creating the Application Shell - probably a couple posts
    8. Wiring the Components with an IoC tool - Forthcoming, but I may push this off into late summer
    9. A Day in the Life of a Screen - by popular demand (gripe), let's look at a couple of complete screens through their entire lifecycle

     

    Introduction

    In building enterprise software systems I've often observed a feeling that building the actual User Interface is less demanding or important in terms of design compared to the backend.  We worry quite a bit about the appearance and the usability of the User Interface, but how about the code structure of the UI itself?  In my experience, UI behavior changes more often than anything else and generates a much higher defect rate.  Several years ago I briefly used Use Case Points as an estimation technique.  One of the features of this technique that caught my eye at the time was how it treated user interface features.  Any feature that included an interactive user interface was automatically given a higher modifier of effort than the same size feature that only dealt with other computers.  In that technique it was a given that interfacing with a human was more complex than interfacing with other code.  My point being here that user interface development is complex and we need to take it seriously.

    A couple years ago heavy clients were out of style due to well-founded concerns over deployment and support issues.  Lately, or at least for me anyway, heavy clients seem to have made a comeback as the newer .Net technologies have alleviated the deployment concerns somewhat.  Instead of dying away, we're building more complex WinForms user interfaces than ever before.  There's a lot of talk about building "composite" applications that can quickly host multiple, logical applications or applets in the same application shell.  We're trying to build applications that can be easily extended without ripping up the existing code.  We're sold on Test Driven Development, but the user interface has remained one of the last uncharted territories for automated testing.  The traditional approach towards building user interfaces in the Microsoft is to fire up the designer and pump energy and effort into it until it works.  That has to change.

    At DevTeach 2007 I gave a talk called "Put Down that Wizard!" with a subtitle "Design Patterns for Maintainable WinForms."  By and large, the talk was about how to code and design a WinForms application.  I discussed design patterns for assigning screen responsibilities, screen synchronization, and issues that effect testability of user interface code.  I was fairly happy with the way the talk went and the feedback overall, but a particular comment from an attendee caught my eye:  "the content was obscure."  The criticism itself wasn't bothersome in and of itself, but the fact that these patterns were considered "obscure" definitely bothered me.  Designing software is largely an exercise in determining the responsibilities of the code and assigning these same responsibilities to different modules of the code.  How you assign, or fail to assign, responsibilities has a great impact on the maintainability of a codebase.  Patterns like Model View Presenter are a reoccurring recipe for assigning responsibilities in a user interface.  These patterns weren't created or invented, they were discovered by practitioners who began to describe the structures that worked (or didn't work).  If we're going to build and evolve more complex user interfaces, we can't blow off the internal structure of the user interface code.

     

     

    What's this series about anyway?

    At DevTeach 2007 I was part of a panel on the tenuous relationship between Microsoft and the Open Source community.  At some point in the panel discussion and the resulting blog discussions afterward, we set off an argument about whether or not the Composite Application Block (CAB) framework was necessary or even valuable for building larger, maintainable WinForms applications.  My point of view then, and now, is that understanding the core concepts and patterns is the first step.  I don't think you can use the CAB effectively unless you understand the underlying patterns.  On the other hand, if you understand the underlying patterns and design forces, you can quite efficiently and effectively do your own thing.  Either way, you want a strong core of design principles. 

    User interface technologies change.  I'm sure it'll take a while, but WPF screens will eventually eclipse WinForms and who knows what's over the horizon.  The specific knowledge that you carry around about WinForms widgets will be obsolete soon.  I think the Microsoft community stresses API knowledge too much and core design principles too little.  When I switched jobs last fall I knew I was going to need a better foundation on WinForms, so I bought and read one of the more popular books on WinForms by a Microsoft luminary (and I say this without any irony).  I read the book and it presented the technology behind WinForms very effectively.  The wizards and designer support was well covered, but the book didn't address the issues of maintainability and testability in WinForms development.  There wasn't a single mention of any kind of View/Controller separation in the entire book.  That's a huge gap in knowledge, and one I hoped to help fill by writing this series. 

    The way it's unfolded, this series isn't really about replacing the CAB with your own Model View Presenter pattern.  It's just the things you can do to make a maintainable WinForms architecture -- with or without the CAB.  A large chunk of maintainability for me is creating code that's easy to test with granular unit tests, and you'll see this desire for testability permeating the entire series.  Despite rumors to the contrary, it is possible to Test Drive WinForms development, but you testability has to be a first class design goal.

    One of the other points I wanted to get across in my DevTeach talk was that oftentimes a code-centric approach can accomplish user interface tasks faster and with less duplication than using the designer.  I'm just now starting to explore some of these code-centric solutions through the later posts involving Fluent Interfaces.  The designer is great for laying out the look and feel, but we can't allow the designer to be our architect.  I don't think WinForms is a bad technology at all, but it's deeply flawed in the sense that it does not lead you into a maintainable structure.  The designer makes it relatively easy to crank out user interface code, and that's what it's doing behind the scenes, but some judicious code-centric design can eliminate duplication and reduce the overall effort.  Maintainability is your job, not the designer's.

     

    So hotshot, you think you can build a better CAB?

    No, I don't, that's not my point.  My point was just that if you were well armed with an understanding of the underlying design patterns and motivation that you could happily evolve your own application specific framework that would better fit your application.  Part of that belief is that building a framework is much simpler in this day and age of Dependency Injection tools.  Today, you can pull one of a couple different Inversion of Control / Dependency Injection tools off of the shelf that are all more powerful than the limited ObjectBuilder inside the CAB.  Then again, I'm the progenitor of one of those tools, so my opinion might be somewhat suspect.

    And yes, to be honest, like many developers there's an inner demon inside of me that arrogantly believes he can build a better [insert name of framework] and is just dying to prove it. Begone inner demon, begone!


    Posted Wed, Jul 25 2007 9:21 PM by Jeremy D. Miller

    [Advertisement]

    Comments

    University Update-Open Source-The Build Your Own CAB Series Table of Contents wrote University Update-Open Source-The Build Your Own CAB Series Table of Contents
    on Thu, Jul 26 2007 12:48 AM

    Pingback from  University Update-Open Source-The Build Your Own CAB Series Table of Contents

    Jeremy D. Miller -- The Shade Tree Developer wrote Managing Menu State Part 2 - The Presenter's get a Layer SuperType
    on Thu, Jul 26 2007 10:52 AM

    The complete "Build your own CAB" Table of Contents is now up if you've missed some of

    Jeremy D. Miller -- The Shade Tree Developer wrote Build your own CAB #14: Managing Menu State with MicroController's, Command's, a Layer SuperType, some StructureMap Pixie Dust, and a Dollop of Fluent Interface
    on Thu, Jul 26 2007 10:57 AM

    The title is a mouthful and accurately implies an alarmingly high jargon to code ration, but I just didn't

    Mo Khan: My Blog! wrote ADO.NET On the Brain
    on Tue, Aug 21 2007 8:48 AM
    Blake wrote re: The Build Your Own CAB Series Table of Contents
    on Thu, Aug 23 2007 4:12 PM

    Great series!  Eagerly awaiting the next installment!

    Jeremy D. Miller -- The Shade Tree Developer wrote I'm speaking at DevTeach Vancouver
    on Tue, Sep 25 2007 7:16 AM

    I thoroughly enjoyed DevTeach the first time around and hope Vancouver goes just as well. I'm giving

    Jeremy D. Miller -- The Shade Tree Developer wrote Best of the Shade Tree Developer Part II
    on Thu, Oct 18 2007 9:21 AM

    About a year ago I hit a patch where I wasn't able to blog much (something about finding a new job

    Jeremy D. Miller -- The Shade Tree Developer wrote Build your own CAB #15 - MicroControllers
    on Sun, Oct 21 2007 9:13 PM

    After a bit of a hiatus and a fair amount of pestering, I'm back and ready to continue the "Build

    on Fri, Oct 26 2007 1:29 AM

    Time for another weekly round-up of developer news that focuses on .NET, agile and general development

    Jeremy D. Miller -- The Shade Tree Developer wrote Resources from my DevTeach talks
    on Thu, Nov 29 2007 12:03 PM

    To everybody that attended one of my talks at DevTeach this week. All of the materials are now online

    Jeremy D. Miller -- The Shade Tree Developer wrote New Year, New Challenges, and an MVP
    on Tue, Jan 1 2008 1:02 PM

    Happy New Year to everybody! 2008 is going to be an exciting year for me and my family. All we've

    Jeremy D. Miller -- The Shade Tree Developer wrote Do you even need to Build your own CAB?
    on Wed, Jan 9 2008 5:43 PM

    There's yet another (worthy) discussion going on in the altdotnet list about whether or not to choose

    Jeremy D. Miller -- The Shade Tree Developer wrote Build your own CAB: Extensible Pub/Sub Event Aggregator with Generics
    on Fri, Jan 11 2008 1:36 PM

    There's been a bit of chatter today on the altdotnet list about whether to use the CAB, another framework

    Jeremy D. Miller -- The Shade Tree Developer wrote Build your own CAB #17: Boil down the "wiring" to a Registry
    on Tue, Jan 15 2008 2:28 PM

    The other umpteen parts of the series are here in the Table of Contents . A large part of building a

    Jeremy D. Miller -- The Shade Tree Developer wrote Build your own CAB: It's mostly fundamental
    on Tue, Jan 15 2008 3:58 PM

    Yesterday I was part of a lot of conversations about building composite desktop applications. The people

    AntonioGanci wrote Leggere il codice scritto da altri - il progetto open source StoryTeller
    on Mon, Jan 21 2008 5:52 AM

    Leggere il codice scritto da altri - il progetto open source StoryTeller

    Rob Kitson wrote Keeping UI construction DRY
    on Fri, Jan 25 2008 2:47 PM

    Keeping UI construction DRY

    Jeremy D. Miller -- The Shade Tree Developer wrote You want examples for Build your own CAB? Here they are.
    on Fri, Jan 25 2008 3:04 PM

    Rob Kitson has put together a set of code examples that demonstrate the screen patterns mentioned in

    Bob on Medical Device Software » Blog Archive » Selecting a MVC/MVP Implementation for a Winforms Project wrote Bob on Medical Device Software » Blog Archive » Selecting a MVC/MVP Implementation for a Winforms Project
    on Fri, Feb 1 2008 11:39 AM

    Pingback from  Bob on Medical Device Software  » Blog Archive   » Selecting a MVC/MVP Implementation for a Winforms Project

    Jeremy D. Miller -- The Shade Tree Developer wrote Build your own CAB #18: The Command Executor
    on Fri, Feb 15 2008 12:13 PM

    The rest of the Build your own CAB series can be found at the table of contents . There's a thread

    David Mc. wrote re: The Build Your Own CAB Series Table of Contents
    on Fri, Feb 15 2008 2:05 PM

    Love love lovin this series Jeremy!

    I think your Table of Contents and the individual articles numbering systems are starting to get out-of-sync though...

    Elegant Code » Microsoft releases Unity, an IoC library wrote Elegant Code » Microsoft releases Unity, an IoC library
    on Sun, Feb 17 2008 10:41 PM

    Pingback from  Elegant Code » Microsoft releases Unity, an IoC library

    Jeremy D. Miller -- The Shade Tree Developer wrote Build your own CAB: The Main Players in the Composite Application Neighborhood
    on Sat, Mar 8 2008 2:21 PM

    I spent a week in Redmond in January taking part in a focus group on the vision for the P&P's

    nblog wrote Tfs Spotlight – buduję własny CAB
    on Tue, Mar 11 2008 7:06 AM

    Od kilku miesięcy nic tu nie pisałem (oczywiście poza poprzednim nieplanowanym wpisem ). Jak łatwo się

    the cab wrote the cab
    on Thu, May 15 2008 7:42 AM

    Pingback from  the cab

    Jeremy D. Miller -- The Shade Tree Developer wrote The great thing about me is that there's so many of me
    on Tue, Jul 29 2008 4:49 PM

    Geek points for identifying the movie quote from the title. Okay, I'm going to get this completely

    Community Blogs wrote The great thing about me is that there's so many of me
    on Tue, Jul 29 2008 5:35 PM

    Geek points for identifying the movie quote from the title. Okay, I'm going to get this completely

    The great thing about me is that there’s so many of me - taccato! trend tracker, cool hunting, new business ideas wrote The great thing about me is that there’s so many of me - taccato! trend tracker, cool hunting, new business ideas
    on Thu, Jul 31 2008 11:39 AM

    Pingback from  The great thing about me is that there’s so many of me - taccato! trend tracker, cool hunting, new business ideas

    Offshore Software Product Development wrote re: The Build Your Own CAB Series Table of Contents
    on Thu, Aug 14 2008 5:27 AM

    Great stuff... I am waiting for new article on this subject...

    tero » The Perils of Autonomous View wrote tero » The Perils of Autonomous View
    on Wed, Sep 3 2008 12:43 PM

    Pingback from  tero » The Perils of Autonomous View

    Presenter First ??? A bibliography « CodeForNothing wrote Presenter First ??? A bibliography « CodeForNothing
    on Sun, Sep 7 2008 5:08 AM

    Pingback from  Presenter First ??? A bibliography « CodeForNothing

    Caliburn Alpha fuer WPF und Silverlight wrote Caliburn Alpha fuer WPF und Silverlight
    on Mon, Oct 13 2008 12:54 AM

    Pingback from  Caliburn Alpha fuer WPF und Silverlight

    Information is not knowledge » Now with added syntax highlighting wrote Information is not knowledge » Now with added syntax highlighting
    on Tue, Nov 4 2008 9:27 AM

    Pingback from  Information is not knowledge » Now with added syntax highlighting

    .NET / WPF Datenbindung und Validierung: Frameworks oder Bibliotheken? | hilpers wrote .NET / WPF Datenbindung und Validierung: Frameworks oder Bibliotheken? | hilpers
    on Sun, Jan 18 2009 5:51 AM

    Pingback from  .NET / WPF Datenbindung und Validierung: Frameworks oder Bibliotheken? | hilpers

    engine wrote re: The Build Your Own CAB Series Table of Contents
    on Sun, Feb 22 2009 8:48 AM

    To everybody that attended one of my talks at DevTeach this week. All of the materials are now online

    David Starr's Blog wrote Code Cast 23 – Jeremy Miller on StructureMap
    on Tue, Feb 24 2009 12:13 PM

    The Shade Tree Developer joined Elegant Coders Jan Van Ryswyck and Chris Brandsma to talk about several

    .NET & Funky Fresh wrote The Caliburn Beta is Live
    on Thu, Feb 26 2009 9:15 PM

    Today is a long awaited day for me.  Caliburn is now in official Beta.   There have been many

    Community Blogs wrote The Caliburn Beta is Live
    on Thu, Feb 26 2009 9:22 PM

    Today is a long awaited day for me.  Caliburn is now in official Beta.   There have been many

    Ishak wrote The Caliburn Beta is Live
    on Fri, Feb 27 2009 3:36 AM

    If you are in the WPF or Silverlight world, you may have spent some time trying to figure out how to

    Silverlight Travel » The Caliburn Beta is Live wrote Silverlight Travel » The Caliburn Beta is Live
    on Fri, Feb 27 2009 4:58 AM

    Pingback from  Silverlight Travel » The Caliburn Beta is Live

    Colour Coding wrote Alt.Net and Adoption
    on Fri, Mar 6 2009 7:58 AM

    Alt.Net and Adoption

    Silverlight Travel » The Caliburn Beta is Live wrote Silverlight Travel » The Caliburn Beta is Live
    on Sat, Mar 14 2009 1:33 AM

    Pingback from  Silverlight Travel » The Caliburn Beta is Live

    Samnang wrote re: The Build Your Own CAB Series Table of Contents
    on Sun, Mar 15 2009 9:12 PM

    Great series, waiting for a complete pdf format + code?

    Jeremy D. Miller wrote re: The Build Your Own CAB Series Table of Contents
    on Sun, Mar 15 2009 9:15 PM

    @Samnang:

    Book, 1st Qtr 2010 maybe.

    new ThoughtStream("Derick Bailey"); wrote Decoupling Workflow And Forms With An Application Controller
    on Sat, Apr 18 2009 2:04 PM

    One of the big problems I’ve been trying to solve recently, is in my current WinForms application that

    maridob wrote re: The Build Your Own CAB Series Table of Contents
    on Wed, Apr 29 2009 4:51 PM

    Great articles! where is the sample code now?

    Uri Lavi wrote Separate Domain from Presentation – part II
    on Tue, May 19 2009 3:27 PM

    This is a second post in the series of posts about “Separate Domain from Presentation” Refactoring. Previous

    Jeremy D. Miller -- The Shade Tree Developer wrote Yes, I'm going to finish "Build Your Own CAB" (sorta)
    on Mon, Jun 1 2009 5:26 PM

    Over the past couple years I've received quite a bit of positive feedback on my " Build Your

    Ben Arroyo wrote re: The Build Your Own CAB Series Table of Contents
    on Wed, Jun 10 2009 10:04 AM

    "... so I bought and read one of the more popular books on WinForms by a Microsoft luminary (and I say this without any irony)..."

    What book is that one?

    Prjesh Anand wrote re: The Build Your Own CAB Series Table of Contents
    on Thu, Aug 20 2009 12:18 PM

    CAB (Cashing Application Block) in the Enterprise Library is been implanted to simplify development tasks but due to it’s in process and standalone behavior it reduces the performance of the application which is not in most case tolerate able. This drawback can be overcome by using third party integrations including NCache which is free available and can be tested for the performance and scalability

    Prjesh Anand wrote re: The Build Your Own CAB Series Table of Contents
    on Thu, Aug 20 2009 12:20 PM

    CAB (Cashing Application Block) in the Enterprise Library is been implanted to simplify development tasks but due to it’s in process and standalone behavior it reduces the performance of the application which is not in most case tolerate able. This drawback can be overcome by using third party integrations including NCache which is free available and can be tested for the performance and scalability

    Florian Fanderl wrote re: The Build Your Own CAB Series Table of Contents
    on Wed, Sep 9 2009 11:19 AM

    Hey :) great stuff in here! Thanks for all those nice concepts as I'm pretty new to "real" OOP.

    I'm currently developing my first project using this technique and I'm pretty convinced that this is by far the best attempt to develop new software.

    The only thing that makes me sad is, that you haven't finished all topics. I'd love to read the rest of this Post :)

    Thanks anyways and keep the stuff coming!!!!

    Raúl Lorenzo wrote re: The Build Your Own CAB Series Table of Contents
    on Thu, Sep 24 2009 7:29 AM

    This documentation is fantastically great!!! It helps me to clear my doubts about different approaches with MPV/MVC which makes me confused a lot.

    When will be available next chapters?

    Anyway, thanks for publishing this knowledge

    Raul Lorenzo wrote re: The Build Your Own CAB Series Table of Contents
    on Thu, Sep 24 2009 7:31 AM

    This documentation is fantastically great!!! It helps me to clear my doubts about different approaches with MPV/MVC which makes me confused a lot.

    When will be available next chapters?

    Anyway, thanks for publishing this knowledge

    new ThoughtStream("Derick Bailey"); wrote Understanding The Application Controller Through Object Messaging Patterns
    on Tue, Dec 22 2009 10:06 PM

    Earlier in the year, I posted a few times on the Application Controller pattern that I was implementing

    Jeremy D. Miller -- The Shade Tree Developer wrote Slide Deck from Advanced Presentation Patterns at CodeMash
    on Thu, Jan 14 2010 7:05 AM

    Since I had the request for this, the slide deck that I used yesterday at CodeMash in my marathon talk

    Salam wrote re: The Build Your Own CAB Series Table of Contents
    on Tue, Feb 2 2010 9:19 AM

    Source code of the examples:

    code.google.com/.../browse

    Just wanted to do something good in return to the great posts...

    Add a Comment

    (required)  
    (optional)
    (required)  
    Remember Me?
    Devlicio.us