News for hackers. Stuff that matters.
Re:Don't Be Clever by jader201 on Thursday August 03, 2023 @09:37AM (#36985702)
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.

Re:Don't Be Clever by sodapopcan on Thursday August 03, 2023 @09:55AM (#36985966)
Yes, 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.

Re:Don't Be Clever by xyzzy4747 on Thursday August 03, 2023 @09:57AM (#36986001)
This is also something the Rust language does well with macros. It’s a pretty standard approach.
Re:Don't Be Clever by fuzzy2 on Thursday August 03, 2023 @10:54AM (#36986798)
This 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.
Re:Don't Be Clever by jader201 on Thursday August 03, 2023 @11:12AM (#36987007)
I'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/s...

Re:Don't Be Clever by hgsgm on Thursday August 03, 2023 @11:44AM (#36987429)
That'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.

Re:Don't Be Clever by tomjakubowski on Thursday August 03, 2023 @12:47PM (#36988319)
Well 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.
Re:Don't Be Clever by abraae on Thursday August 03, 2023 @01:24PM (#36988876)
To be perhaps even more anal, after construction scaffolding is taken down, stored, transported to a new project and then used again.
Re:Don't Be Clever by oefnak on Thursday August 03, 2023 @07:26PM (#36993438)
And it's made of steel, not bits.
Re:Don't Be Clever by gorlilla on Friday August 04, 2023 @04:29AM (#36997109)
If there are no bits then what're all the pieces linked to?
Re:Don't Be Clever by paulddraper on Thursday August 03, 2023 @02:36PM (#36989860)
Then that makes it an inappropriate word for both uses.
Re:Don't Be Clever by nenaoki on Friday August 04, 2023 @06:40AM (#36998026)
* * *
Re:Don't Be Clever by fuzzy2 on Thursday August 03, 2023 @03:08PM (#36990320)
It’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.
Re:Don't Be Clever by Pxtl on Thursday August 03, 2023 @12:45PM (#36988289)
If 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.
Re:Don't Be Clever by paulddraper on Thursday August 03, 2023 @02:34PM (#36989834)
Correct.

The number of comments which latch onto "code generator" without understanding it are disappointing.