The Watch
example in Chapter 9 used a data-driven approach for the Java state machine, but more
procedural code for the C state machine. As a general guideline, the lower the level
of the target language you are generating, the less likely it is that you will choose a
data-driven approach.
Howcan the domain framework offer an interface for the generator to use? Largely
in the same way as any component framework: it can provide utility functions, data
structures to be instantiated, ways to attach behavioral code generated from the
FIGURE 12.4 Parts of a DSM solution
318 DOMAIN FRAMEWORK
models, customizable and extensible components, and an architecture that works with
all these. Utility functions will be familiar from other frameworks, and were covered
in Section 12.1, so we will concentrate on the other ways.
12.3.1 Data Structures to be Instantiated
In many cases at least some of the modeling language concepts will appear in the
domain framework as data structures with similar contents. This is obviously the
case for a generator for a modeling language that offers a graphical front end for an
XML schema. There each object type will tend to map to an element with attributes or
subelements for each property, as we saw in Section 11.3.4. Generation of other
textual DSLs will work similarly. Even where the generator produces mostly
executable code rather than data, some parts of the model will normally be represented
directly in data structures.
Pages:
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596