Computational thinking is a way of approaching problems so a computer can help solve them. Two of its key skills are decomposition and abstraction; the others are pattern recognition and algorithm design.
Decomposition
Decomposition means breaking a large problem into smaller, more manageable sub-problems, and repeating until each part is simple enough to solve directly. Each part can be designed, coded and tested separately, and different people can work on different parts at once.
Example: “build a library system” breaks into:
- Manage members (add, edit, remove)
- Manage books (add, search, remove)
- Handle loans (issue, return, calculate fines)
- Produce reports (overdue books, popular titles)
“Handle loans” can then split further: check the member is allowed to borrow, check the book is available, record the loan, set the due date. In code each sub-problem usually becomes a procedure or function, which supports reuse and makes testing easier.
Abstraction
Abstraction means hiding unnecessary detail and keeping only what is relevant to the problem. A map of the London Underground ignores real distances and curves because passengers only need the order of stations and the connections. The result is a simpler model that is easier to reason about.
In programming abstraction appears in many forms:
- A function hides how a task is done; the caller only needs to know what it does and what it needs.
- A data type such as a stack hides how the items are stored.
- A class hides internal data behind a few methods.
- A variable name abstracts a memory address.
Choosing the right level of abstraction is a skill. Include the details your solution needs and leave out the rest. For a school timetabling program, a teacher is a name, a list of subjects and availability, not a height or favourite colour.
Putting it together
A typical approach to a problem is:
- Define the problem and its inputs and outputs clearly.
- Abstract away detail you do not need.
- Decompose into sub-problems.
- Look for patterns, so repeated tasks become one reusable routine.
- Design an algorithm for each part, then test each separately and then together.
Benefits are easier maintenance, fewer errors, simpler teamwork and reusable code libraries.
Check your understanding
What is decomposition?
- Removing detail
- Breaking a problem into smaller sub-problems
- Compressing data
- Repeating a loop
Answer: Breaking a problem into smaller sub-problems. Each can be solved and tested separately.
Why does the Underground map ignore real distances?
- To save ink
- It uses abstraction to show only the details passengers need
- It is incorrect
- The distances are secret
Answer: It uses abstraction to show only the details passengers need. Extra detail would make it harder to use.
How does decomposition usually appear in program code?
- As comments
- As separate procedures and functions
- As variables only
- As one huge loop
Answer: As separate procedures and functions. This gives reuse and easier testing.
Which is an example of abstraction in programming?
- Calling a function without knowing how it works inside
- Deleting a file
- Increasing RAM
- Typing faster
Answer: Calling a function without knowing how it works inside. Only the interface matters to the caller.
