Monday, March 15, 2010

User controls suck.

I have rcently had occasion to go back to developing windows forms wigets and have reaffirmed my opinion that the UserControl model is a huge mistake for anything other than a one-off solution to a simple problem.
There are many problems with the model. First, the principle of polymorphism in a UserControl is utterly destroyed by the use of events within the user control. As soon as a UC has an initializecomponent that has event subscriptions then it is impossible to derive from the UC in any meaningful way because certain behaviours are set in stone and may not later be modified.
Another problem is the lazy way aggregation of function is treated by developers who utterly miss the boat with simple principles. An example being a job I'm working on now to replace a UC that is designed to emulate the function of a combobox with a datagrid in the dropdown.
This type of aggregation is uneccesary when we go back to the base functionality of the combobox and use the system of messages and overrides to create a real combobox that hosts something other than a lame listbox in the dropdown.
Even when dealing with Windows Forms the immediate reflex seems to be look at as high a level solution as possible and to ignore the underlying elegance of the system.

2 comments:

青椒 said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.