Grade 9 Computer Science · Abstraction

Naming a thing and forgetting the detail

What everything learned so far shares, and why it is one idea.

Seven things in mind, a million lines of code

A person can hold only a handful of things in mind at once, and yet people write programs of millions of lines and understand what they do. A better memory does not explain it. The explanation is one idea you have already used for three years — without anyone giving it a name.

For three years we have learned things that look different: functions, modules, data structures, protocols. Now it can be said what they all share — because they really are one idea, and it is the only one that makes it possible to build software of a size anyone actually uses.

The user reads only the upper one; the lower exists and is not needed.
The abstractionWhat it hides
A functionThe lines inside it
A data structureHow the values are arranged in memory
A protocolHow the information actually travels

Why without it nothing is possible

A person holds about seven things in mind at once. Real software contains millions of lines. That gap is not closed by a better memory or by concentration — it is closed by needing to hold in mind, at any given moment, only one layer: the names of what is beneath, and not their contents. Whoever writes a function using ten other functions holds ten names, not ten thousand lines. That is the whole trick, and there is no other.

Example 1 — why it is one idea

  1. Each of them has a name.
  2. Each has a promise of what it does.
  3. In each there is detail that was hidden.
  4. And the hiding is exactly the benefit.

Example 2 — how much is held in mind

  1. The function uses ten others.
  2. Each of them is a thousand lines.
  3. Whoever writes holds ten names.
  4. And not ten thousand lines.
On each card ask: what can I leave unknown when I use this?