11.4.3 Generator per File Type
Each model may generate more than one ?¬?le: as mentioned above, there may indeed
be a many-to-many relationship between models and ?¬?les. This is problematic for
generators based on templates or the model visitor pattern. While generation into
multiple ?¬?les may be possible, you tend to ?¬?nd yourself working against the tool rather
than with it. API-based generators can of course cope, and stream-based crawler
generators come into their own.
There can be several different reasons why more than one ?¬?le may be generated
from a single model. In some languages, the implementation may require multiple
?¬?les, for example, a .c and .h ?¬?le for C programs. In other languages, standard practice
may encourage them, for example, a Form1.cs C# program may have a separate
partial class for its UI de?¬?nition, Form1.Designer.cs. These cases are predictable, with
one model always giving a pair of ?¬?les. More complicated cases are also common, for
300 GENERATOR DEFINITION
instance because the modeling language represents information in a signi?¬?cantly
condensed form.
One DSM model may simply contain the same information content as several
source code ?¬?les. A fair part of this reduction is removal of redundancy, which can be
split into two parts. First, each source code ?¬?le contains signi?¬?cant similarities to other
?¬?les of the same type.
Pages:
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561