Automated Code Generation (Page 3)
<< Introduction & Message Forum
<< Page 2 (What is a Code Generator?)
How do Code Generators Work?
As stated earlier, anything which is repetitive can be automated.
Given the correct conditions, a lot of source code can be automatically
generated - the programmer is then free to "fill in the gaps".
The question is, under what conditions can code be automatically
generated?
For code to be generated, the following three vital areas must
be 100% predictable and well understood:
|
|
1. The Design Patterns (the
template to which the code will be produced)
2. The Domain Meta-Data (the
topology that we are attempting to model in code, usually
augmented with extra data provided by the developer)
3. The Domain Rules (the rules
that dictate the structure and behaviour of the domain meta-data.
This area is normally encapsulated in the generator program
itself)
|
The data itself can of course be wild and unpredictable, as long
as it fits within the above constraints.
Under what conditions are code generators
especially beneficial?
Generators are best applied to a problem domain that involves many
short, similar iterations. A good example is a database API, where
the same design pattern is applied over and over to a series of
database tables. The structure of each table might be unique, but
the rules and conditions applied to each table are the same.
Under such conditions, it can even become quicker to write the
generator itself than it would to hand craft the source code (not
to mention the time saved if the database changes and the code must
be rewritten, either partially or in its entirety).
>> Page 4 (Types of Code Generator)
<< Back to Programming
|