- [Craig] In this video, we're thinking about the computational thinking concept of decomposition.
(uplifting piano jingle)
Decomposition, along with abstraction and algorithmic thinking,
is one of the three principles of computational thinking which you need to be aware of at GCSE.
Decomposition simply means breaking a complex problem down into smaller, more manageable parts.
If you're to become a successful programmer, this is a core skill.
You need to be able to take the overall problem and break it down into its constituent parts,
and then solve each of those individual parts, which make it easier to solve the overall problem.
Dealing with many different stages of a problem all at once
is much more difficult than breaking a problem down into a number of smaller problems
and tackling those one at a time,
and this process is what's known as decomposition.
Now, you engage in problem decomposition in your everyday life without even thinking about it,
from getting up in the morning, getting dressed, brushing your teeth,
finding your way to school and then approaching your homework at the end of the day.
These are all complex problems that you break down in your mind without giving it a second thought.
If we take this everyday example of crossing a road,
then the first thing you're going to do is stop before crossing the road,
you're going to look left and right, and if the road is completely clear,
you may be able to cross the road without engaging in the Pelican crossing at all.
However, if there's traffic, you're going to take a different decision
and you're going to press the button and you're going to wait for the lights to go red.
When the lights have gone red,
you're then going to look left and right just to be sure there isn't a car jumping the lights,
and then you're going to begin to cross the road.
So, even the everyday activity of crossing the road can be broken down into smaller sub-problems.
Let's think about this in terms of creating a simple computer game.
A breakout clone allows the player to move a paddle left and right
at the bottom of the screen and a ball bounces around the screen hitting tiles.
When it hits a tile, they disappear.
The object of the game is to clear all the tiles without losing the ball.
If the ball is travelling towards the bottom of the screen
and the player doesn't hit the ball with the paddle, then he loses the ball.
So, let's think about how we'd approach programming this game.
At first, it might seem very complex.
It seems unmanageable, but if we break it down into its constituent parts,
it starts to feel like it's possible.
So, where we might start would be getting the paddle to be displayed on the screen.
Then we might get the paddle to interact with the user by allowing them to move it left and right.
We might then think about some validation programming.
We don't want the paddle to go off the left-hand side of the screen or off the right-hand side of the screen.
We might then draw the ball,
followed by getting the ball to accurately bounce around the screen.
We then might write the code to draw our tiles,
followed by getting the ball to detect when it's hit a tile.
We may then add into our game some winning and losing conditions,
and then at this point, we might start to add some flair to the game such as the special effects and the sound.
It's also at this point we might start to improve our graphics
because up until this point, we've probably just used very simple graphics
so we could get the program working.
So, this was an example of how we may approach a typical computer game.
It feels very difficult to achieve until you start breaking down the problem
and solving the individual constituent parts.
And again, this is problem decomposition.
So, the advantages of problem decomposition include making a problem easier to solve.
Different people can work on different parts of the problem at the same time,
and this will reduce development time and cost.
In our computer game, you might have some artists working on the graphics,
you may have a special effects team that's able to work on the particle effects,
and you may have an audio team working on the sound.
You also have program components that, developed in one program,
can then be easily used in other programs,
making future iterations of the game much easier and quicker to develop.
(uplifting piano jingle)