5.1 - Decomposition & Abstraction
What is computational thinking?
Computational thinking is an approach to solving complex problems by making them processable by a computer. This method is used in computing, but it also applies to everyday challenges.
Computational thinking consists of 3 key components that work together to address problems:
- Decomposition - Breaking a large problem into smaller, more manageable parts
- Abstraction - Identifying and focusing on the essential information while removing unnecessary details
- Algorithm design - Creating a step-by-step plan or set of instructions to solve the problem logically
These elements allow programmers and problem-solvers to handle complexity without getting overwhelmed.
Decomposition in computational thinking
Decomposition is the process of dividing a big problem into smaller sub-problems. This makes each part easier to solve than trying to handle everything at once.
Examples of decomposition
Decomposition can be applied to both real-world situations and computing tasks.
Real-life example: Building a bridge
A construction company tasked with building a bridge in a city could use decomposition to make the project more approachable.
Key sub-problems:
- Determine the materials required for the bridge.
- Calculate the necessary size and dimensions of the bridge.
- Estimate the number of workers needed.
- Identify the machinery and equipment required.
Each sub-problem is simpler to solve than the entire bridge-building task, allowing the team to focus on one aspect at a time.
Computing example: Creating a racing game
A game developer designing a racing game could decompose the project into smaller, testable components.
Key sub-tasks:
- Design and create graphics, such as cars, tracks, and characters.
- Develop sound effects for elements like engine noises and crashes.
- Program the movement mechanics for the cars.
This approach enables testing of individual parts, like car movement, before integrating everything into the full game. Top-down design might be used to outline the game's structure.
Abstraction in computational thinking
Abstraction is the technique of filtering out irrelevant details from a problem to focus on the information that matters. This simplifies the problem, making it easier to solve.
Benefits of abstraction
- It reduces complexity by ignoring non-essential elements.
- In computing, it transforms real-world information into data that a computer can process.
To apply abstraction, always consider the specific goal of the problem – this guides what to keep and what to discard. Different situations may require different levels of detail, so the abstraction can vary accordingly.
Examples of abstraction
Abstraction is useful in everyday scenarios and computing, where it helps highlight key elements while discarding distractions.
Real-life example: Writing a cookie recipe
Imagine observing a chef baking cookies on a television programme and wanting to create a recipe. Abstraction involves noting only the vital details and ignoring the rest.
| Relevant information (to keep) | Unnecessary information (to ignore) |
|---|---|
| Quantities of each ingredient | Brand names of ingredients |
| Sequence for mixing ingredients | Equipment used for mixing |
| Baking time and temperature | Make or size of the oven |
By focusing on these essentials, the recipe becomes straightforward and replicable, without extra details that do not affect the baking process.
Computing example: Modelling a rail network
A programmer building a program to simulate train movements on a rail network could use abstraction to create a simplified model.
Key elements to include:
- Position of each train on the network.
- Direction each train is travelling.
Representation in the model:
- Trains as simple shapes, like triangles with arrows indicating direction.
- Tracks as straight or curved lines.
- Stations as circles.
Details to ignore:
- Number of carriages on each train.
- Number of passengers.
This abstracted model contains all the necessary data for tracking train flow, such as assigning numbers to track lengths for distance calculations. For instance, the computer could add these numbers to find the total distance between stations. If the program needed to calculate travel times, distances might be included, showing how abstractions adapt to the problem's requirements.