Hacker News new | ask | show | jobs
by p2t2p 3068 days ago
This style has quite high cognitive load, how many 'and then's can you hold in you short term memory until you loose the context completely?

I believe the the art of programming is actually writing the code in a way that transitions the reader through context changes keeping the amount of context necessary to understand what's going on to a minimum.

2 comments

I strongly agree. I usually express this as "minimizing complexity", but I like the "guiding through context changes" phrasing.

One of the best things about humans is how easy it is for us to work at multiple levels of abstraction simultaneously, as long as we're guided to and between them properly. Good code - hell, good engineering - exploits this to create things which otherwise wouldn't fit in a person's head.

Or, how little can you make the reader have to think and still be able to really understand the code? There's a sweet spot there, where either simpler (or more simplistic) or more complicated is a net loss to the reader.

The problem is, the location of the sweet spot depends on the reader (or at least, on their familiarity with the idioms used...)