Fig. 12.6 shows an example of inner classes being used to accomplish the
same behavior as the overriding of the ???perform??? function above.
A fourth way to integrate generated code into the framework is via direct injection:
changing the framework code itself. This is only viable where only one piece of the
FIGURE 12.5 Framework calling a generated function
PROVIDING AN INTERFACE FOR THE GENERATOR 321
application wants to change any given piece of the framework. If multiple con?¬‚icting
changes were needed to the same piece of the framework, there would be no way to
reconcile them to satisfy all the requirements. While the framework could in theory be
duplicated for each case, making the application contain multiple edited copies of it,
in that case it could hardly be considered a framework.
We have seen cases where a framework is literally edited via a script or macros, but
this is best saved as a last resort (or for those who ?¬?nd themselves unaccountably short
of war stories). Some languages, for instance C, offer a preprocessor which allows the
de?¬?nition of macros. The framework can then contain references to the macro, and the
generator de?¬?nes its code into the macro de?¬?nition in a separate ?¬?le. Aspect-Oriented
Programming systems allow the use of separate code ?¬?les which are then woven into
the framework at speci?¬?ed points.
Pages:
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602