Abstraction
The Art of Ignoring
Abstraction means focusing on the details that matter and hiding the ones that don't. It is the third tool of computational thinking, and it sounds strange at first β surely more detail is better?
Not when you are solving a problem. Detail costs attention, and attention is limited.
The Map Is Not the City
The best example of abstraction is in your pocket: a map.
A subway map shows stations, lines, and connections β and throws away real distances, street names, buildings, and geography. It is "wrong" about almost everything, yet perfect for its purpose: telling you which train to catch.
Different purposes need different abstractions of the same city:
| Map | Keeps | Hides |
|---|---|---|
| Subway map | stations, lines, connections | distances, streets, buildings |
| Road map | roads, junctions, distances | pipes, cables, house numbers |
| Tourist map | landmarks, museums, parks | everything residents need |
The details worth keeping depend on the purpose. That single sentence is the heart of abstraction.
Abstraction Hides Complexity
Every device you use is wrapped in abstraction:
- You press a kettle switch β you do not manage heating elements and thermostats
- You tap an envelope icon β you do not handle the network machinery that moves an email
- You press a key on a keyboard β you do not track the electrical signals it sends
Each gives you a simple interface to a complicated machine. The complexity still exists β you just never have to think about it. Computer systems are built as layers of abstraction, each layer using the one below without knowing its inner details.
Naming Is Abstracting
Here is a form of abstraction you will use constantly when writing algorithms: giving a name to a chunk of steps.
TO make_tea:
boil the kettle
put teabag in cup
pour water into cup
wait 2 minutes
remove teabag
Once make_tea is defined, other algorithms can just say make_tea β five steps hidden behind one name. Combined with decomposition, this is how huge programs stay understandable: big named pieces made of smaller named pieces.
Worked Example β Describing a Car
"Describe a car" has no single right answer β it depends who is asking:
- Parking app: length, width, height. Nothing else.
- Racing game: top speed, acceleration, handling.
- Environment report: fuel type, emissions.
Same car, three abstractions. None of them mentions the driver's favourite radio station β a detail that matters to no purpose here. Choosing an abstraction means asking: "What does this task actually need to know?"
Abstraction in Every Layer of Computing
Once you notice abstraction, you see it holding up every topic in this course. When you use a variable called numberOfLives, you are abstracting away the exact memory location where that number is stored β you only need the name. When you call a function like sortList(), you are abstracting away the sorting algorithm's inner steps β you only need to trust that it works. When your operating system shows a "Save" button, it is abstracting away which exact storage device and file format is involved underneath. Even hexadecimal is a small abstraction over binary β a friendlier costume for the same bits.
This reveals something important: abstraction is not one specific technique you use once and move on from β it is a way of managing complexity that appears at every level, from a single named variable up to an entire operating system. Each layer hides the one below it, and trusts that the hidden layer does its job correctly. That trust is what lets one person build a website without personally understanding transistors, and what let the engineers who built those transistors do so without personally understanding every website that would one day run on them.
When Abstraction Goes Wrong
Abstraction is powerful, but hiding detail always carries a small risk: sometimes the hidden detail does matter, and the abstraction leaks. A subway map is a wonderful abstraction β until you need to know it's actually a 20-minute walk between two stations shown as neighbours, and you end up late because the map abstracted away exactly the detail you needed. In programming, this happens when a function's name promises something its code doesn't quite deliver, or when a "simple" interface hides a slow or unreliable process underneath. Good abstraction requires judgement: hide almost everything, but not the one detail someone genuinely needs.
Key Words
- Abstraction β hiding unnecessary detail to focus on what matters for the purpose
- Model β a simplified representation of something real (maps, diagrams, game physics)
- Interface β the simple controls an abstraction exposes (a switch, an icon, a name)
- Layer β a level in a system that uses the layer below without needing its details