We encounter abstractions around us every day. They can be shortened versions of something, to give an example of the whole thing. For example, the British television programme Match of the Day only shows highlights of football matches; music websites allow you to stream excerpts of upcoming albums; and the blurb on the back of a book gives only an indication of the whole story.
Abstractions can also be symbols that are used to convey meaning while reducing complexity. Examples are road signs, the London Tube map, class timetables, and infographics.
We also regularly entertain abstract ideas in our day-to-day living. For example, most of us have only a notional understanding of most of the machines we use. We use the terms ‘car’, ‘microwave’, and ‘mobile phone’ without really knowing what they do, and without having any concept of how they work.
Word problems in mathematics are a great example of abstraction. Pupils need to choose (abstract) the relevant information from the description in order to create the number sentence that solves the problem.
Abstraction in computer science
Within computer science, abstraction is one of the key elements of computational thinking. Barefoot Computing states that “abstraction is about simplifying things — identifying what’s important without worrying too much about detail,” whereas educational researcher Keith Turvey says that “abstraction is a process by which any unnecessary detail is omitted in order to help us to solve a problem or achieve a specific outcome”.
One of the aims of England’s National Curriculum for Computing is to ensure that all pupils “can understand and apply the fundamental principles and concepts of computer science, including abstraction, logic, algorithms, and data representation”.
Abstraction allows us, as computer scientists, to concentrate on the important bits of developing a solution by ignoring the irrelevant detail — much in the same way as pupils do for maths word problems.
For example, we may have been asked to create an algorithm for making a cup of tea. In our algorithm, we can ignore some of the complexity that this task would entail, such as how to use a kettle, and use (abstract) instructions such as “switch the kettle on” in order to make our algorithm simpler and easier to understand.
Abstraction in Scratch
The majority of programming languages are abstractions. They hide the complexity and, for us humans, the incomprehension of the binary instructions that computers use. A lot of the keywords and commands within programming languages, for example the print and input commands, also abstract more complex tasks.
Within Scratch, there are a number of blocks that abstract the processing that is being performed under the hood. Figures 1 and 2 below show two such blocks, and you can see the steps that are hidden from the user in their captions.
Abstraction lesson idea using Scratch
Using decomposition and the PRIMM (Predict–Run–Investigate–Modify–Make) pedagogical approach to structuring programming lessons (see the boxout for more details), we can unpick another of the Scratch blocks to begin to understand how abstraction works.
Take your class through the following steps, referencing Figure 3:
Ask your students to look at the code and ask them, “What does this code snippet do? What will happen to the sprite?”
Get your students to run the program and ask them, “Does the code do what you thought it would? If not, can you work out why?”
Ask your students to label and comment on the code. You can ask questions like, “What does each block do? What do the numbers represent? What happens if you change the numbers?”
Ask students to alter the code to make the sprite bounce on the left-hand edge of the screen too.
Get students to add code to make the sprite bounce at the top and bottom of the screen too. Ask them what they will have to change to test this code. For an added challenge, ask students to try and replicate the ‘If on edge, bounce’ block.
Abstraction using My Blocks
Using My Blocks in Scratch is an excellent way to develop understanding of abstraction. In creating an abstraction, pupils need to fully understand what information needs to be hidden from the user.
One of the complexities of teaching Scratch to younger children is the need for them to understand coordinates and the use of negative numbers to control the movement of a sprite around the stage. We can use abstraction to hide those complexities by creating new blocks to move left, right, up, and down. Take students through the following steps:
What do you think the block in Figure 4 will do?
Using the ‘When right arrow key is pressed’ block, run the ‘Move right x steps block’. Does it do what you thought it would?
Investigate the block definition in Figure 5. How does it work? Will it work for all directions?
Can you create other blocks for moving left, up, and down?
Can you create another block called ‘Stay on screen’, to stop the body of the sprite going off the screen? Can you then amend the ‘Move right’, ‘Left’, ‘Up’ and ‘Down’ blocks to include this ‘Stay on screen’ block?
Jeanette Wing, who is recognised as having defined computational thinking, refers to abstraction as the most important thought process in computer science. Abstractions are everywhere in computing: they hide the complexity of the underlying processes, whether that complexity is in an algorithm, a program, the computer itself, or your own understanding of what the internet is. As with all tricky concepts, the more practice and examples you engage with, the more concrete the notion becomes — even with something as abstract as abstraction.
The PRIMM approach
PRIMM is a pedagogical approach to structuring programming lessons. It follows the below structure:
Discuss the program and predict what it might do; what will be the output?
Run the program to test the predictions.
Explore the structure of the code, using tracing, explaining, annotating, debugging, etc.
Edit the program to change its functionality via a sequence of ever more challenging exercises to gain confidence by extending the function of the code.
Design a new program that uses the same structures but solves a new problem.
You can read more at: helloworld.cc/primm.