Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are advantages and disadvantages of code generation? [closed]

There are probably different kinds of code generation. In RoR for example, Rails can create skeletons for models, controllers, etc. But the developer has to complete those skeletons.

Now some times there are projects where many core artifacts in their entirety get generated according to a set of definitions or models.

I am mainly interested to know the advantages and disadvantages of this latter type of code generation.

like image 946
Behrang Avatar asked Jan 20 '23 20:01

Behrang


1 Answers

The main advantage is that it does the work for you, its repeatable, and that the code will most likely work (that depends of course if the person who wrote the generator knew what they were doing). It can remove the a lot of necessary time doing menial coding tasks. For example, is it really worth your time to write objects which are nothing more than containers for data from the database, or is it better to have some program automatically create these for you?

The big disadvantage is that it forces you into writing the code that is compatible with the generated code. Most of the time this isn't a problem, but it can be a real hassle when someone comes up to you and says "Hey, can we do X?" and that conflicts with the generated code. If the generator is good, it will allow you to change functionality, but that almost always increases the complexity of the code generated etc. This complexity has a price. It's more difficult to understand, and it can be less efficient that code you write yourself. This of course varies by situation.

like image 142
kemiller2002 Avatar answered Feb 05 '23 18:02

kemiller2002