IDE Generated Code

code generationide

Many IDEs have the ability to spit out automatically written pieces of code. For example, it might generate a getter/setter pair for you. I wonder whether it isn't an attempt to work around some flaws in the language. If your IDE can figure out what the code should be without your help, why can't the compiler?

Are there cases where this is a really good idea? What kind of code generation does your IDE provide? Would the same thing be better provided as a feature of the language?

Best Answer

The difference between the IDE auto-generating some code and building that directly into the language is very simple: I can edit the code after the IDE generates it.

The IDE can generate some code template for a getter/setter, and then I am free to add additional functionality to that getter/setter as my requirements dictate. If the getter/setter was an integrated part of the language, then if I ever wanted to customize the behaviour, I'd have to write the getter/setter myself anyway...

Related Topic