The code for a ???Save As??? dialog would thus be likely to be found as a fairly long
boilerplate section in a DSM generator. Some features of the dialog may be picked up
from the model and used to affect the generated code, either being output to become
REMOVING DUPLICATION FROM GENERATED CODE 313
parameters to the call, or being used as conditions in the generator to cause different
?¬?xed text parameters to be output.
Within any given product built with theDSM language and generator, this solution
will look all right: the code will probably appear only once or twice. Across the whole
product family, however, the code will appear many times. While this duplication also
occurred in handwritten code, it was spread over so many developers and so much
time that developers rarely felt a pressing need to refactor it.
In a way, the generator already provides a good refactoring: the boilerplate code
appears only once in the generator de?¬?nition, and all occurrences in the code are
produced automatically from that. However, this still leaves many occurrences in the
code. The time-honored principle of avoiding duplication is thus not yet fully applied.
The principle is so well proven, and such an integral part of DSM, that a deep costbene
?¬?t analysis is probably unnecessary: a few examples should suf?¬?ce.
Pages:
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587