Programming and Cognitive Load (2019)

Programming and Cognitive Load.
Producing maintainable software depends on readable code, and readable code depends on controlling cognitive load. By recognising that code reading is essentially a learning process, and considering how each line of code we write will be processed in the mind of the reader, we increase our chances of creating understandable, maintainable software.

Read in full here:

This thread was posted by one of our members via one of our news source trackers.

2 Likes

Corresponding tweet for this thread:

Share link for this tweet.

1 Like

A look at the cognitive load required between two pieces of code of different levels of abstraction. The argument put forward being that the higher the extraction level (i.e. class, framework) the bigger the cognitive load. So should we use frameworks or fancy design patterns and abstract away all the detail? How does that effect maintaining and modifying the code?
It really comes down to the individual developer’s experience. If you know what the class or framework does then you probably don’t need to go looking that much, therefore your cognitive load is lower. But a junior developer would require a bigger cognitive load to understand the code because of not knowing that class or framework.
I am a big believer in design patterns as a way to reduce duplication and make way for ease of code expansion. But I am not so much a big fan of massive frameworks or libraries that do magic things that when they break it’s a nightmare to find out why.
I try to code for the poor person who will be after me.

Coincidently, I just finished reading The Programmer’s Brain which is a complete book around how our brain works when we code. Working memory, short term memory (STM), long term memory (LTM), implicit & explicit memories, cognitive & germane loads, naming things and even onboarding new people. It’s quite a packed little book.
Well worth the read if this sort of stuff peaks your interest.

4 Likes

Thank you for the book suggestion. That might be useful for me.

3 Likes

@andrea - if you do pick it up let me know what you think.

2 Likes