There are so much different user case for code generation, some are, some are not. I actually started my first internship by writing a code generator. The goal was to automate all the copy pasted layer based on the entity definition. While i did enjoy that task, the resulting architecture mean that you have a whole lot of (automatically) copy pasted code and add I believe most dev agree, code duplication is usually a code smell. We could argue that if it's generated, then you don't really have to maintain it, but i would if as a dev you have to open those file, debug through then, then it does impact the code/architecture quality. In those case, they're often better code pattern and architecture to reach your goal.
On the other side, any kickoff code generation is good imo, like yeoman or maven archetype. Those tool will generate all the boilers plate code to start your project but then it becomes your code and you clean it up as a first step and never use the generator again.
On a similar pattern of generate once, Django migration are also a good example. It take a few seconds to generate the db migration script, they are easy to review and customize but it become your own code afterwards. Bonus point, once deployed, you never go back modifying it in this case.
Then there is what is call "background code generator" haven't seen a lot of them, it's code that get generated but you will never have to see it or debug through it, the only example that come to mind is Project Lombok even if we might not consider it purely a code generator that would also be fine to me as it simplify boiler plate code that really no one cares about.
I'm the end, the most important question to me is, after the code is generated, what will be the cost to me maintaining that code. Of the answer is more than writing it myself or using some other pattern, then it's a no go. The reason is simple, as a dev, we will spend way more time maintaining every single line of code than initially writing them.
There is also another factor to take into consideration, what feature your language allow. Java is really poor in dynamically creating interface or object attribute which make it more likely to see a benefit from code generation. In the other side, python or JavaScript can create new interface and attribute on the fly and thus are way less likely to need code generation since the language is flexible enough too write generic code that since the same problem
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There are so much different user case for code generation, some are, some are not. I actually started my first internship by writing a code generator. The goal was to automate all the copy pasted layer based on the entity definition. While i did enjoy that task, the resulting architecture mean that you have a whole lot of (automatically) copy pasted code and add I believe most dev agree, code duplication is usually a code smell. We could argue that if it's generated, then you don't really have to maintain it, but i would if as a dev you have to open those file, debug through then, then it does impact the code/architecture quality. In those case, they're often better code pattern and architecture to reach your goal.
On the other side, any kickoff code generation is good imo, like yeoman or maven archetype. Those tool will generate all the boilers plate code to start your project but then it becomes your code and you clean it up as a first step and never use the generator again.
On a similar pattern of generate once, Django migration are also a good example. It take a few seconds to generate the db migration script, they are easy to review and customize but it become your own code afterwards. Bonus point, once deployed, you never go back modifying it in this case.
Then there is what is call "background code generator" haven't seen a lot of them, it's code that get generated but you will never have to see it or debug through it, the only example that come to mind is Project Lombok even if we might not consider it purely a code generator that would also be fine to me as it simplify boiler plate code that really no one cares about.
I'm the end, the most important question to me is, after the code is generated, what will be the cost to me maintaining that code. Of the answer is more than writing it myself or using some other pattern, then it's a no go. The reason is simple, as a dev, we will spend way more time maintaining every single line of code than initially writing them.
There is also another factor to take into consideration, what feature your language allow. Java is really poor in dynamically creating interface or object attribute which make it more likely to see a benefit from code generation. In the other side, python or JavaScript can create new interface and attribute on the fly and thus are way less likely to need code generation since the language is flexible enough too write generic code that since the same problem