Computational Thinking

Lesson 3 of 5

Abstraction

Filter out unnecessary details and focus strictly on what matters most to build clean models.

🟡 Intermediate 75 XP

Learn it

Think about a map of the London Underground. It does not show every curve in the track, the trees above ground, or the depth of the tunnels. It only shows stations and train lines!

This is abstraction: hiding the messy, complicated details so you can focus only on the important information you need to solve a problem.

When you drive a car in a video game, you press a button to accelerate. You do not need to know how fuel injection works under the bonnet. The complex engine mechanics are abstracted away!

Key terms

Abstraction
Filtering out irrelevant details to focus on the essential features of a problem or system.
Model
A simplified representation of a complex real-world process or system.
Information Hiding
The principle of concealing internal implementation details behind a clean public interface.
Encapsulation
Bundling data and the methods that operate on that data while restricting direct access to internal components.

Abstracting a Digital Bank Account

Observe how unnecessary physical details are filtered out to create a software model of a bank account.

  1. 1Identify Real-World Details: Physical banknotes, bank branch furniture, vault weight, and paper slips.
  2. 2Discard Irrelevant Details: Software does not need to know the physical dimensions of the bank vault or the teller counter colour.
  3. 3Retain Critical Data: Keep account number, account holder name, and current numeric balance.
  4. 4Define Essential Actions: Implement deposit, withdraw, and transfer operations while hiding the internal ledger updates.

Abstracting a Vehicle in Code

pythonclass Vehicle:
    def __init__(self, model):
        self.model = model
        self._speed = 0

    def accelerate(self):
        # The user does not need to manage fuel injection or piston timing
        self._speed += 10
        return f"{self.model} speed is now {self._speed} km/h"

car = Vehicle("Electric Hatchback")
print(car.accelerate())

The driver calls accelerate() without needing to control the complex underlying physics or engine simulation. The detail is abstracted away.

Try it

Evaluate these statements about computational abstraction:

Abstraction means adding as many fine details as possible to make a program realistic.

A map of the London Underground is a classic real-world example of visual abstraction.

High-level languages like Python abstract away binary machine code and CPU registers.

Abstraction makes complex systems harder to maintain and understand.

Challenge

Design an abstract data model for a digital library book. List the essential properties and methods you would include, and name three real-world details you would discard.

Pick whichever way suits you — every mode earns the same bonus XP.

Write at least 40 more characters to submit.

Mark your own work

Guided walkthrough — 0/5 clues revealed

  1. Clue 1 locked — reveal it only if you get stuck.
  2. Clue 2 locked — reveal it only if you get stuck.
  3. Clue 3 locked — reveal it only if you get stuck.
  4. Clue 4 locked — reveal it only if you get stuck.
  5. Clue 5 locked — reveal it only if you get stuck.

Each clue costs 4 XP (never below 19 XP). You'd earn 38 XP right now.

Extension: Write a Python class representing this abstract LibraryBook with borrow() and return_book() methods.

Quiz time

Question 1 of 4Score 0

Which statement best defines abstraction?