|
Code generators are software constructs that write software. It is code-writing code. Code generation is a technique already common on development projects. The code wizards offered by most integrated development environments (IDE) are a form of template-driven code generation with which most of us are familiar. Other examples include the forward-engineering capabilities of modeling tools and the use of the Java decompiler (JAD) to reverse-engineer Java source from bytecode. The use of code generation techniques is wide and varied, but code generators can be loosely categorized as either passive or active [Hunt, 1999].
The distinction between active and passive code generation is a subtle one and essentially comes down to how the generated code is maintained over the course of the project. If the code generator is made part of the build process and generates fresh source each time a build is instigated, then we are using active generation. If the output from the same generator is taken by the software engineer, modified, and placed under source control, then we have passive code generation. Both techniques can save time and effort, although the two techniques are applied quite differently. These next sections examine the uses of each type of code generation. |
|