Wednesday, December 21, 2011

Custom Controls vs. Extensions

Did you know that, although I have previously voted for extensions, my experience with LightSwitch helped me realize that in some cases custom controls can be more effective than extensions or even handle issues extensions are not meant to handle.

When special manipulation and user interaction has to be handled (like drag’ n’ drop handling especially between differently typed collections) although extensions can be employed, IMHO, the plumbing needed to achieve the desired goal is to be taken under serious consideration. In general the question to be answered, as to whether one should implement an Extension Control or a Custom Control, is if the effort needed to extract the general behaviors and characteristics required by the entities to be handled and thus generalize the control, is worth it. And by “worth it” I mean what are the chances one will be able to reuse it.

There are cases that very special data manipulation requirements need to be met (once and maybe never again). In these cases a “Project” Custom Control (proprietary terminology) is the best solution. By “Project” I mean a custom control that is aware of the domain. Created in the Client project maybe or any other project with a reference to the Client project. The Client project apart from being aware of the domain has also direct reference to the concrete client LightswitchApplication with all the plumbing required to have access to the concrete Dataworkspace.

One thing is for sure, as soon as you have a custom control operating without having concrete reference to your domain and application, you have a perfect candidate for a Control Extension and you should implement it as soon as possible.

No comments:

Post a Comment