If that is the case, and the classes really are
singletons, it will probably be an implementation choice whether to simply move the
name and the static, class-side variables to be instance variables. Examples of this
can be seen from the Watch Java code in Fig. 12.4: do we really need a new class
DisplayX334, or could we simply change its superclass, AbstractDisplay, so it could
be concrete?
Domain Frameworks Contain More Metaprogramming Since most bugs
are found in code not data, good programmers generally look for chances to turn code
into data. In simple cases this can be easy and natural, but in less obvious cases the
code needed to read and enact the data becomes complicated. The use of a
programming language with good support for metaprogramming can help a lot here,
but still the code requires an above-average programmer. Unfortunately, the vast
majority of programmers consider themselves ???above average,??? just as most automobile
users consider themselves better than average drivers . . . To put it another way,
324 DOMAIN FRAMEWORK
in the right hands metaprogramming is a powerful tool, but wielded inexpertly it can
wreak havoc with the readability and quality of your code. For this reason,
frameworks are a particularly good place for metaprogramming: it is fair to expect the
developer of a framework to be a better programmer than the users of that framework.
Pages:
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607