The
comments also contain a checksum of the original generated code, so the generator
can check if the region has been edited. Other solutions are of course possible:
GENERATOR OUTPUT PATTERNS 295
for example, for the DSM tool to remember the line numbers and checksums of
the regions without adding comments to the ?¬?les. This is however prone to problems:
for example, if ?¬?les are replaced so the ?¬?le on disk is no longer the previous generated
?¬?le whose information has been remembered by the tool. Region comments also
make the task of editing the ?¬?les easier, by clearly showing which regions are
protected.
There are a number of other details still to be covered, but we shall skip them here
because protected regions cause more problems than they solve. They force DSM
users to work on the models, the generated code, and the hand-edited code, and mix
the latter two up in a troublesome way. Both models and code ?¬?les need to be
versioned, so the same information is recorded twice. Although protected regions may
feel familiar from round-trip UML tools, there are better ways of achieving the same
results.
Handwritten Code in Models Rather than adding handwritten code to a
generated ?¬?le, the code can be added to the model. Obviously, this should be avoided
as far as possible, but when handwritten application code is a necessity, putting it in
the models allows you to keep a single source containing all necessary information.
Pages:
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550