Code generation can be defined as the process by which a given compiler’s code generator converts a given piece of source code into machine code i.e. code that can readily be executed by a machine such as a computer. The code generators usually try to optimize the code that has been generated in a particular way. For instance, the generators can choose to use faster instructions, they can choose to exploit the available registers or even avoid redundant computations in an effort to optimize the code. The method chosen is usually dependant on the code generator used.
Here are a few things you should know about code generation and code generators in general.
First of all, there are different types of code generators. Depending on your project and the type of code that you’re working with you are destined to find something that works for you. That said; these code generators all have similar characteristics that should be pointed out.
For one, code generators make applications more secure. They eliminate the embedded SQL statements that make code brittle and difficult to debug and in the process improve the performance of the application. In Code generation, it also store procedures and parameterised queries to prevent SQL injection attacks that can compromise the application.
Code generators also have a standardized development approach. They are built with a consistent design and architecture that allows developers to move easily and shift from one project to another.
They are also consistent. Machine code generated by code generators tends to change the way programmers and developers work for the better. This is largely due to the fact that the code generated is simpler and much cleaner since it performs what is required at the moment. If for some reason the requirements change later then a simple modification of the code generator is required to crank out a new version of code. Opting for another code generator is also advisable if it is suitable for your requirements.
Stability is another characteristic of code generators. They are known to be very stable and bug free. This is primarily because code generators are debugged when they are first written and as such the bulk work of debugging has already been carried out even before the generators start the projects assigned to them.
In short, code generation does the work for you and saves you a lot of time that you could have spent doing menial coding tasks. A good example of a menial coding task is creating objects that are nothing more than containers for data from a given database. This can easily be carried out by a code generator and completed in a much shorter time frame.
In conclusion, as a developer you should keep in mind that there are different kinds of code generation like Java code generation, html, asp, etc. and it is your responsibility to find the one that best works for you. If you work with Ruby on Rails for example, the rails can create skeletons for your controllers and models but it is up to you, the developer, to complete these skeletons.
Image may be NSFW.
Clik here to view.

Clik here to view.
