Hacker News new | ask | show | jobs
by pjbster 981 days ago
To my mind, all discussions about code design boil down to the reduction of cognitive load (CL).

“Cognitive load refers to the amount of effort that is exerted or required while reasoning and thinking. Any mental process, from memory to perception to language, creates a cognitive load because it requires energy and effort. When cognitive load is high, thought processes are potentially interfered with. To the UX designer, a common goal when designing interfaces would be to keep users’ cognitive load to a minimum.”

(https://speakerdeck.com/fedepaol/reducing-cognitive-load-yet...)

In this context, "users" can be substituted with "other developers". Writing low-CL code is a constant balancing act and, like good UX design, when it works the nuances are invisible and therefore hard to learn from.

So I appreciate the OP for the article even if we can quibble about some of the points.

1 comments

There is no one metric of code quality. There are a bunch of competing concerns, some of which will push others down if you push them up.

With cognitive load it doesn't even generalize. Who hasn't worked with somebody who joined a project and then immediately started changing the code to be more aligned to their taste in idioms to reduce the cognitive load. Their cognitive load that is. Not necessarily anybody else's.

First day of a new job, a new commute all have exceedingly high cognitive loads. Come back from that, all you did was just HR stuff and a new commute and are exhausted! After a year, suddenly that commute, the byzantine policy stuff has a cognitive load of, "yeah, this is all super simple."

My point, the unfamiliar might have actually lower cognitive load. Cognitive load is a function of what you know and what you are used to.