Of course, it is best to keep such coupling to a minimum: the generated
code is allowed to expect certain things of the handwritten code, but generally not the
reverse.
In the simplest cases, the generator can output include or import statements in
the generated code to refer to the handwritten code. The generator should also
produce a list of the referred ?¬?les, and check that they exist. If there are more than a
few such ?¬?les per model, it may be easier to move the pieces of code from each
being a ?¬?le to each being a function, with all functions from one model contained
in a single ?¬?le.
296 GENERATOR DEFINITION
At this point, we have moved into the territory of programming in general. Tactics
to allow further expansion of this idea include automatically generating placeholder
functions, which can be overridden by handwritten code in a concrete subclass.
Moving further in this direction, however, takes us out of the domain of DSM and into
the kinds of solutions we see in older modeling tools. As those tools have failed to raise
developer productivity, if we ?¬?nd ourselves adopting their tactics we would do well to
step back and reconsider our DSMsolution. Handwritten application code is not quite
the epitome of evil, but neither is it by any means a necessary evil.
11.4 GENERATOR STRUCTURE
In many ways, writing a generator is just a special case of writing a program: there are
as many different ways to structure the same behavior as there are programmers.
Pages:
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552