It de?¬?nes
???perform??? only as an abstract method. The code generated from the Stopwatch model
is a subclass of that, and provides a concrete implementation of the ???perform??? method
320 DOMAIN FRAMEWORK
to specify its own actions: setting various time variables and turning the stopwatch
icon on or off.
Second, the framework can provide hooks, events or callbacks, and the generated
code can declare its generated functions as handlers for these. This allows a large
degree of freedom and variation in how the application takes advantage of the
framework. In third party component frameworks, such an approach demands good
judgment and architecture from the framework provider: all too often the point at
which you would need to step in and have your code executed is not offered by the
framework. In a domain framework, that is easily remedied; a good architecture is
however still needed.
Where the implementation language permits it, the second way can also be
extended far enough that it could be considered a new, third way. The framework can
offer data structures, some of whose members are pieces of code. Some languages, for
example, C, allow named function pointers to be used in this way; others such as
Smalltalk allow arbitrary anonymous blocks of code. Java can use inner classes,
although their syntax and the multiplicity of compiled ?¬?les leave something to be
desired.
Pages:
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601