liveBook · Manning

Cognitive load

As explained in The Coder Cafe

Cognitive load is the mental effort required to understand, modify, or reason about information or a system.

Cognitive load is the mental effort needed to understand code, add a feature, or fix a bug. It matters because someone must still be able to read and change the code years after it was written. section 4.4 section 4.0

The source of that effort matters:

  • Intrinsic load comes from the task itself. A complex banking domain remains complex even when its code is clear. section 4.4
  • Extraneous load comes from how information is presented. An API that mixes levels of abstraction makes a task harder without helping solve the underlying problem. section 4.4

You cannot remove every difficulty, but you can avoid adding unnecessary ones. Working memory is limited: even reproducing a 20-line function, including its variable names, from memory is difficult. section 4.4

Reduce avoidable load where people encounter it:

  • Make code easier to follow by reducing nesting, simplifying conditions, and keeping related behavior together. section 4.4
  • Use abstractions when they add clear value; premature or inconsistent abstractions can make later work harder. section 4.4 section 4.3
  • Keep README files, comments, and tests clear and current so they help people understand the system. section 4.4
interface Delivery {
  public void deliver(DeliveryList items);
}
class DeliveryList {
  private List coffees;
  // Other items can be added as needed
}

The DeliveryList interface illustrates an abstraction around the product idea of delivery, rather than a separate method for every literal requirement. section 4.3

The concern extends beyond code reading. During an outage, pressure and cognitive load can make a sequence of events look causal or make an early hypothesis seem better supported than it is. Recognizing those traps calls for deliberate discipline. section 7.6

How The Coder Cafe covers it

How deep it goes
Defines intrinsic and extraneous load, then gives practical ways to reduce avoidable effort without proposing a formal measurement method.
Examples
Uses a complex banking domain, an inconsistent API, a 20-line memory challenge, and a delivery interface.
What it assumes
Introduces the load categories from zero while assuming familiarity with ordinary tasks such as reading code and fixing bugs.
What you can do after
Apply it by separating unavoidable task difficulty from avoidable presentation costs and simplifying code, abstractions, and documentation.
How it connects
Connects to working memory, API design, abstraction, documentation, and incident analysis.

Also explained in

Compare how 8 books explain cognitive load →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Coder Cafe. The section links point to the parts of the book it draws on.