Anxiety. This is a feeling I’ve been learning to recognize as a SIGN when I’m coding.The feeling you get when the camera gets really close on the face of the pretty girlas she walks around the empty, and silent, house. Is she going to turn around suddenlyand be given flowers? Or is the disemboweling only moments away. You don’t know, butyou’re cringing either way.
I’ve felt this in the past about data access layers. This is the feeling I’ve beenaccumulating around my Windows Forms application lately. I don’t want to code. I’mafraid to code. It’s going to be painful. I’m not sure what’s going to go wrong. Butsomething will, and I’ll be sucked into the unproductive death pit.
Having spent a bit of time feeling around the problem, I’m pretty sure what I don’tlike is having to deal with events. Let’s take a look at the reason why:
Windows forms makes things easy.
Click click click! I have a button and I have an event linked to it. Amazingly productive.My app will be running in no time.
Event Handlers are teh awesome.
It’s so easy to link an action to an event handler. Well. It’s pretty easy. It’s veryeasy within one class. Not so bad if you’ve got a reference to the object that containsthe event handler. A little bit of encapsulation makes it harder. Chained event handlerscan fix that though……
All is happy with one form per task.
This form is easy. Add a few buttons and it’s great. If you’re prepared to make yourapplication out of a bunch of forms that the user will work with one-by-one, there’sno problem.
However….sovereign apps don’t look like that.
If the user is going to be in one application all day long, it will have to provideeasy access to a number of different types of functionality. The application can’tconsolidate all of the interface elements required for a single task into a singleplace. Rather there’s a spaghetti monster of functionality, reaching it’s noodleyappendages everywhere.
Events flying every which way, and everything needs a hard reference to everythingelse.
Can you actually wire all this up with EventHandler references? Sure. Of course youcan. However, you end with a lot of tightly coupled code that is a real mess to createand to maintain.
Hope. The eternal struggle.
A application shell is a complicated beast. But problems have solutions. In my nextpost, I’ll show how you can integrate all these separate components without stranglingyourself in wiring.