Consider code generators
Some types of classes share the same basic structure, and differ only
in details. Type-safe enumerations and data-centric
Model Objects are two examples. In such cases, aids for rapid code generation
become very useful. These may take several forms:
-
a simple template of text intended for copy-and-paste
-
a passive code generator - generates source files which may need
further edits. If further edits are performed, then they will be lost if
the code generator is run a second time.
-
an active code generator - generates source files which will not
need further edits (the idea here is to use the code generator as part
of the actual build, instead of relying on it for a one-time operation)
-
a round-trip code generator - generates source files which may
need further edits. If further edits are performed, then they will not
be lost if the code generator is run a second time, since it will detect
such edits, and use them to update its internal model.
Code generators often use simple, ad hoc textual descriptions as input.
The codegeneration.net
web site is a useful reference for code generation.
The extensive use of code generation is often called Model-Driven Development
(MDD), or Model-Driven Architecture (MDA).