Want to leave a question, comment, or some criticism? Click here!
1. Motivation/Background
Well, I've been doing a lot of Windows Forms development lately and if there's something I've learned it's that the out
of the box RAD approach that the Windows Forms designer offers is just plain terrible. I've seen it dozens of times:
forms that are just out of control, huge, and contain all of the business logic.
The whole thing is really a byproduct of the designer itself: it was meant for RAD and that's how most develoeprs
choose to use it.
A few months back, I decided to try out the [Smart Client Software Factory] from Microsoft for a project that I'm working on
at the moment. I was familiar with the Model-View-Presenter paradigm, but never quite liked it for the complexity of the
interactions and amount of extra work required to implement it properly. I'm a strong believe that the more difficult a
pattern is to implement, no matter the benefits and programming aesthetics, no one will want to use it :-P
To me, MVP is such a pattern. So what are the better alternatives? The SCSF (an excellent library) lead me back to
researching MVP to better understand how the factory was intended to be used and how components are meant to be designed within
the framework of the system. This lead me back to [Martin Fowler's article on MVP], which I found was retired in favor of
two alternatives: [Passive View] (PV)) and [Supervising Controller].
[As I've discussed previously], PV and "[Humble Dialog]" seem to be more aligned with the design of the SCSF.
Fowler writes of Passive View:
[Definition:] A screen and components with all application specific behavior extracted into a controller so that the widgets have their state controlled entirely by controller.
A perennial problem with building rich client systems is the complication of testing them. Most rich client frameworks were not built with automated testing in mind. Controlling these frameworks programaticly is often very difficult.
Passive View has massive potential and upside, in my opinion, to help decouple business logic and data handling from
representation. One of the neatest tricks, I thought, was the way that SCSF allows developers to connect events dynamically.
2. Objective
The objective of this workshop is to:
- Examine PV in simplified terms with .NET code (SCSF is quite heavy and takes a LOT of time to digest)
- Examine how to dynamically connect events which allows flexibility and pluggability in view design
3. Auxiliary Files/Prerequisites
To try this out for yourself, you will need the following:
- .NET Framework 2.0 or .NET 3.0 for anonymous method support.
4. What is It?
6. Wrap Up
In this workshop, we examined how to create a simple realization of the Passive View (or Humble Dialog) GUI design
pattern. We also examined a trick way to dynamically wire events to controls to help decouple view implementation
from business logic. Along the way, we also took a brief look at generating IL and the powerful
DynamicMethod class.
7. Resources
Additional resources for further exploration: