Even then, the changes
cannot be made ad hoc to the generated ?¬?le, or they will simply be lost when
regenerating after subsequent changes to the model.
It is important here to differentiate between handwritten code that will be the same
for all (or many) applications in the domain, and code that must be written by hand for
a single part of a single application. The former forms the domain framework, which is
written by theDSMsolution team, and will be covered in the next chapter. The latter is
written by the modeler of the application in question, and it is on such handwritten
application code that we focus here.
Handwritten application code can be integrated in three ways:
. Protected regions
. Handwritten code in models
. Files referenced by models
Protected Regions A protected region is a section of the generated ?¬?le that is
known by the generator to be possibly edited by hand. When code is regenerated, the
generator reads that section of the ?¬?le on disk. If it has been edited, the contents of the
region on disk are preserved, overriding that section of the newly generated version of
the ?¬?le.
To make this possible, the regions are generally delimited by specially formatted
comments. The generator recognizes such comments and can parse information
from them to link that region with the corresponding region in the new output.
Pages:
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549