Going further down in
search of Code For Real Men works no better: machine code is even simpler, and the
processor just chews that stuff up like a 1960s BASIC interpreter. In a last attempt to
salvage some pride, the Real Developer pulls out self-modifying code; the database
guy looks on with pity: ???so you ?¬?nally have some data that??™s not read only. Of course,
we??™ve never seen anything like that. . .???
Clearly, the search for a dividing line between code and data is fruitless??”and not
particularly ?¬‚attering to our egos. Let??™s abandon any attempt to ?¬?nd a higher truth
here, and settle for a pragmatic de?¬?nition. If a piece of generated text simply
instantiates and provides values for a data structure, it??™s data; otherwise, it??™s code.
How can a framework provide ways to integrate such code? Obviously, if the code
calls the framework, the problem is trivial, so we shall concentrate on cases where we
want the framework to call the code.
First, the framework can be made to call a speci?¬?c function, and the generator
produces that function. This will normally of course be extended to a number
of such functions. An example can be seen from the ???perform??? function used
in the Watch applications from Chapter 9, as seen in Fig. 12.5. The
AbstractWatchApplication framework class implements a state machine, calling
the ???perform??? method for the actions speci?¬?ed in transitions between states.
Pages:
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600