💾 Archived View for bbs.geminispace.org › u › mediocregopher › 5678 captured on 2023-12-28 at 18:17:41. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-11-14)
-=-=-=-=-=-=-
Re: "I was recently reading other people's code, and I'm..."
How a function gets written depends on its purpose. Some functions need to be big.
A thousand times this. I think a common exercise for new programmers is to take some complex, badly written, monolithic code, and to refactor it into smaller functions. And that's a good thing to practice. But I don't think the converse skill is ever taught, that of identifying when a big chunk of logic should stick together.
Sometimes code is big and complex because the requirements are big and complex. Obviously mental overhead can be reduced with some strategic abstraction, but beyond that I much prefer a giant function which mirrors the requirements than the same thing cut up arbitrarily and scattered around.
Sep 28 · 3 months ago
☯️ oldernow · Oct 29 at 12:53:
It's fun to read about such in a state of retirement from the craft.
I still write an occasional Lua scripts, which occasionally burgeon into something conducive to agonizing over abstraction-motivated structuring. But then I remember that enough time away from such undermines its (alleged) benefits, i.e. down the road I'll be equally mystified whether it be monolithic or separate-file-structured.
Something similar happens to me with comments, because invariably whatever I write won't include context I'm not consciously aware of at time of writing, such that months/years later detailed commenting is no less questionably useful than whatever structuring/non-structuring I may have agonized over.
Also (brace yourself to wince..), I wound up concluding that empty lines in the context of brace/indentation consistency were less helpful to my apprehending what I'd done in the future than being able to see more lines at once without them. Sure, one can also de-magnify to see more, but aging also tends to degrade vision, such that smaller text eventually becomes useless.
Try to take the following as an attempt at humor. I'm going to refactor:
"life sucks and then you die"
to:
"coding sucks and then you pick up a guitar"
:-)
I was recently reading other people's code, and I'm reminded why I don't usually ever do this - I hate reading other people's code. I program very differently than a lot of other people. I don't make tons of 5-line files, but it has become common to make tons of 5-line files, and it just makes your code extremely confusing to navigate. I don't do classes. OOP makes you abstract more than you need to, is extremely confusing to navigate (it almost requires that you make tons of 5-line files, lol)...