Automated Code Generation (Page 5)
<< Introduction & Message Forum
<< Page 4 (Types of Code Generator)
Advantages of Code Generators
Some advantages of auto-generated code are:
 |
Ultra-consistent (machine generated) |
 |
Changes the way programmers work:
code tends to be much cleaner and simpler, as it only needs
to do what is required now. If requirements change later, simply
modify the generator and crank out a new version of the source
code |
 |
Stable and bug-free, "works
first time" (the debugging takes place when writing the
code generator itself - hence the bulk of the debugging work
has taken place BEFORE the project begins) |
 |
Produced very quickly (just point
the generator at the problem domain, and crank out a brand-new,
guaranteed up-to-date API) |
 |
Customisable (assuming you have
the source code for the generator itself, you can easily customise
the code that will be generated) |
 |
Takes change in its stride (if a
database needs to be changed, simply make the change, then turn
the handle and "crank out" a new version of the source
code - takes minutes) |
 |
Programmers are free to concentrate
on the areas of development that deserve their brainpower (hence
morale improves, which further increases productivity) |
 |
Code mentor (as the generated code
is well written and 100% consistent, programmers are more likely
to copy the style of this code and learn from it than they would
a dusty old standards document. So all project code is more
likely to be consistent and very clear, despite being produced
at an incredibly rapid rate) |
Disadvantages of Code Generators
Some disadvantages of auto-generated code:
 |
The code generator must be written
first |
 |
Only applicable given a specific
set of conditions |
 |
There will always be some code that
needs to be hand-crafted. The actual amount varies from project
to project. Usually, the generated code acts as "support"
for this hand-crafted code, i.e. an API |
 |
For database code, the database
must be well formed (i.e. properly designed and normalised).
Generators generally do not cope well with databases that have
special, "unique" design features |
The last item can also be used to the project's advantage, as long
as the database is being designed especially for this project. In
effect, the code generator can be used as a database design validator:
the design should be tweaked and honed until a proper API can be
generated. The database will be much better designed as a result.
This will save a LOT of time later on.
However, if the database was created for an older project, and
has "gone live" with real data, then it might not be possible
to use a code generator. In this instance, the generator could be
customised to cope with the specifics of the database; or the "traditional"
route could be taken, and the API source hand-coded from scratch.
>>
Page 6 (Generators and Agile Projects)
<< Back to Programming
|