3 ms·
I've created a number of code generators in my projects. Invariably, developers say exactly what you just wrote, "how do I modify the generated code"? The ans
by IncRnd 10y ago
I've created a number of code generators in my projects. Invariably, developers say exactly what you just wrote, "how do I modify the generated code"?
The answer is not to modify the generated code. Modify the input to the code generator to make changes.
Even when I output a warning to this effect, that all modifications to target code will get overwritten, not to check the target code into version control, the source code is already checked into version control - invariably developers modify the target code right under the comment that says not to, then they check it into version control. They then wonder why there are bugs, and their modified target code no longer works after the target code gets regenerated after the next build.
- deong 10y agoIt's almost as though you can't solve the problem of programmers making errors by having a different set of programmers whom you tell to not make errors.
- IncRnd 10y agoThe issue had nothing to do with programmers. The impetus wasn't that programmers make errors but to solve the problem of repeatability. Many instances of issues can be solved once. There is no need to recreate the solution a number of times if it is already solved. A code generator allows one to focus on the actual meta-problem, which is often smaller and easier to solve.