12.1 REMOVING DUPLICATION FROM GENERATED CODE
In many ways, DSM is all about removing unnecessary duplication of effort, and
in software development this generally translates into removing unnecessary
duplication of manually written code. The generator plays a central role in this
process, replacing many instances of copy??“paste duplication with one copy of
the relevant code in the generator. Even without DSM, component libraries have
played an important part, allowing a repeated piece of code to be collected into
a component and invoked each time via a signi?¬?cantly shorter piece of code.
A domain framework makes it possible and cost effective to go further than normal
in this area. Let us look ?¬?rst at a concrete example of how the economy of reuse
changes in DSM.
The Windows call to open a ???Save As??? dialog effectively takes 23 parameters,
one of which is any combination of a set of 27 ?¬‚ags (Fig. 12.2). This has two
consequences: the number of different possible dialogs is astronomical and the code
to produce any one of them is substantial. Any given application will however
generally contain only one or a fewsuch dialogs, so the code for the dialog is generally
written by hand??”or more likely copied and pasted from last year??™s project. For many
programmers, the number of calls to such a piece of code is simply not high enough to
persuade them to create their own higher-level dialog function.
Pages:
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586