views:

124

answers:

1

I'm developing a form in a C# .NET 2.0 application that contains complex logic regarding the state (enabled/disabled) of various controls on the form. (The design is a symptom of a business analyst's poor understanding of UI best practices.)

What would be the best way to go about managing the "state" of the form? Normally, I've seen an ShowControls(state) or SetEnables(state) function where state is enumeration of possible configurations (INITIAL, AFTER_SELECT, AFTER_COPY, etc). I predict that this will rapidly become unmaintainable.

What method of maintaining form "state" do you use? What patterns might you involve in keep track of complex control interaction?

+3  A: 

My favorite pattern is the passive view. It removes all state management responsibility from the form. In the end, it makes maintenance of your presentation code much easier, but there's some upfront cost in terms of additional code.

Michael Meadows