DSMoffers particularly fertile ground for metaprogramming. First, special cases are
particularly irksome in metaprogramming. In normal code, an extra IF statement
is neither here nor there, but in the compact yet convoluted coils of a piece of
metaprogramming, any extra complication can easily render the whole hard to
comprehend. Since DSM has already forced a more thorough domain analysis than
normal, such cases can be taken into account in the modeling language or elsewhere, or
at least will be known from the start rather than hacked in as an afterthought. Second,
metaprogramming??”like any data-driven code??”is sensitive to illegal orwayward input
in its data. The metaprogrammer must either write extensive code to check the data or
then crank up their optimism a notch or two. In DSM, the structures and constraints of
the modeling language can ensure that only well-formed and valid data can be entered.
12.3.4 Inversion of Control
A common pattern when using frameworks is to switch the basic execution
architecture: rather than the application code running the showand calling framework
code as needed, the framework itself runs and calls the application code provided to it.
This is known as inversion of control.
The way the inversion works can perhaps be explained by analogy with sports team
coaching.
Pages:
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608