5 ms·
My understanding is that in this case, the code generator is merely a boilerplate generator that isn’t meant to keep the code in sync, but just do the initial c
by jader201 3y ago
My understanding is that in this case, the code generator is merely a boilerplate generator that isn’t meant to keep the code in sync, but just do the initial copy/paste work.
I think code generators are a perfectly acceptable solution in cases like this, when the starting point all looks the same, and it needs to diverge from there. Especially if the generation logic is fairly straightforward.
There are a lot of IDEs that have boilerplate generators out of the box.
- sodapopcan 3y agoYes, this is what the author meant, no doubt. To be clear I'm not being sarcastic. Many frameworks have code generators that writes boilerplate for you.
- xyzzy4747 3y agoThis is also something the Rust language does well with macros. It’s a pretty standard approach.
- fuzzy2 3y agoThis is sometimes also called scaffolding, which I think is a better term. Code generation often means (compile-time or otherwise) generation of code from something else (like .proto definitions). Code that is not supposed to be modified by the developer and will be overwritten automatically.
- jader201 3y agoI've also seen "scaffolding" used to generate code that shouldn't be manually modified. E.g.: https://learn.microsoft.com/en-us/ef/core/managing-schemas/scaffolding/?tabs=dotnet-core-cli https://learn.microsoft.com/en-us/ef/core/managing-schemas/s...
- hgsgm 3y agoThat's someone who doesn't know what words mean. When a building is built, the scaffolding isn't an immutable part of the final product.
- tomjakubowski 3y agoWell if we're being anal about the metaphor, in construction and renovation, the scaffolding eventually goes away. Scaffolded code rarely disappears entirely; some of it usually sticks around.
- paulddraper 3y agoThen that makes it an inappropriate word for both uses.
- deleted 3y ago[deleted]
- fuzzy2 3y agoIt’s a little ambiguous with Entity Framework. There is no rule that says you cannot change the resulting code. If you want to continue with Code First, that is a totally valid approach, there’s even a subsection on that.
- Pxtl 3y agoIf scaffolding is generating more than an SMS worth of code per file, it will drive you crazy because you still want to keep it in sync.
- paulddraper 3y agoCorrect. The number of comments which latch onto "code generator" without understanding it are disappointing.