Re:Simple Ways of Reducing the Cognitive Load in Code
by lmm on Tuesday June 28, 2016 @12:26PM
(#11995075)
I think people underestimate the cost of vertical length. It's less obvious in small examples, but there's a huge difference in readability between a class or function that fits on one page and one that doesn't, so it's well worth making individual lines a bit less readable if it means you need less of them.
[ Parent
| on HN ]
Re:Simple Ways of Reducing the Cognitive Load in Code
by pyre on Tuesday June 28, 2016 @03:25PM
(#11996735)
The question here is with is "a bit less readable"? Many people with run with that advice and start playing code golf on a production codebase.
Re:Simple Ways of Reducing the Cognitive Load in Code
by amirouche on Tuesday June 28, 2016 @01:18PM
(#11995564)
> so it's well worth making individual lines a bit less readable if it means you need less of them
What does it mean?
Re:Simple Ways of Reducing the Cognitive Load in Code
by effie on Tuesday June 28, 2016 @03:29PM
(#11996768)
Our teacher of programming told us something like this: if your program has so many lines it cannot fit on one screen, it contains at least one bug, so don't make them, keep them short. I try to make all projects made of small files, where each one can fit on one screen. Great for comprehensibility and productivity (less scrolling). Sometimes, a procedure gets longer than one screen, so what one needs to do is to put as much source as possible on a line, so that the entire thing fits into one screen.
Re:Simple Ways of Reducing the Cognitive Load in Code
by lmm on Wednesday June 29, 2016 @04:14AM
(#12000198)
Making individual lines a bit less readable is well worth it if making individual lines a bit less readable means you need less of them. ("Worth it" is a construct I don't really understand the grammar of - I'm a native English speaker)
Re:Simple Ways of Reducing the Cognitive Load in Code
by zenojevski on Tuesday June 28, 2016 @03:40PM
(#11996876)
Intermediate functions :)