Do Divide and Conquer

A complex widget implemented as a single, large render method is difficult to maintain and offers no opportunity to reuse its component parts, as it has none. Where a widget renders more than a single value, consider dividing it up into a group of cooperating renderer plug-ins. This will result in smaller, more manageable components. These components can be reconfigured or reused in other contexts to meet future requirements.

Development of a complete renderer can progress toward the final goal in stages. For example, take the widget described in A Details Widget Demonstrating Widget Re-use. This requirement could not be met using multiple fields in a UIM CLUSTER element because the layout would not fit into the strict grid provided by a cluster. However, an alternative approach to its development is this sequence:

  1. Create a UIM page containing a CLUSTER element and place separate fields for the details within the cluster.
  2. Create widgets to render each of the fields a manner closer to that required in the final details widget.
  3. Assess if the solution is "close enough" to be acceptable and release the change if it is.
  4. If the cluster layout is still too limiting, develop a widget to lay out the fields in the required manner. This will require a change to the data to make it a single value, an XML document. Reuse all of the smaller widgets in a rendering cascade.

All of the widgets developed in the second step are reused in the context of the last step. This allows greater flexibility in planning the work, as the functionality can be released early and refined at a later time, if it is still necessary. The individual widgets developed in the second step can also be reused when developing other details panel widgets, or widgets for unrelated purposes.