Once a problem has been decomposed into smaller tasks and any patterns identified, it is useful to examine it, identify what is actually required, and remove any unnecessary elements.
This will help the programmer save time in developing the solution. This process is called Abstraction.
In this lesson, we’ll learn about the process of abstraction:
Once we know what the problem is, we can then start to take steps to identify what data & information is require and what the program needs to do.
For example, looking at the Information Management System from the previous lesson, we know that the program will need to:
From this, we can identify the information required will include:
At this stage, we can also start to filter out any data or information that is not necessary.
If we do not, then there is a real risk that any programmer will attempt to include this information in the programmed solution. This will waste time and money.
One requirement of the IMS is that a teacher can look up attendance details about a specific student.
To do this, they type the student’s surname, click ‘enter’ and information is displayed.
The information needed will be surname only.
This will give us a list of students with the specified surname, but the information brought back may include their first, middle, and last name(s), subject, attendance data, and lesson date and time.
Information not needed is gender, age and date of birth as this is not relevant to the search request.
Abstraction means hiding the complexity of something away from the thing that is going to be using it.
For example, when you press the power button on your computer, do you know what is going on?
Of course not – your computer just turns itself on. That’s all you need to know.
The process of powering up your computer and starting the load process of the Operating System into RAM memory from the boot sector has been hidden from you.
Abstraction in computational thinking is a technique where we split individual parts of the program down into imaginary ‘black boxes’ that carry out operations.
We don’t care HOW the operations are carried out, only that they work consistently and accurately.
For example, in our IMS, there will be a ‘search for a student’ process that uses the Search Abstraction Layer.
The Search Abstraction Layer contains all the functionality to:
The ‘Search for a Student’ process does not know that the Search Abstraction Layer opens a connection to a database and gets a list of search results; all it knows is that it gives the black box a surname and gets back some results.
This is Abstraction: the student search functionality is hidden away from the rest of the system.
Once an abstraction layer has been identified, it can be fully described by its:
This is called defining the Abstraction Layer.
Consider the student search system, it can be represented using the following terms:
Abstraction is hiding the complexities of one part of a computer program from another.
Abstraction is where we identify the information needed to solve a problem.
Abstraction is where we filter out unnecessary details at different stages of solving the problem.
Abstraction Layers are where we group areas of functionality.
We define Abstraction Layers by including variables, constants, key processes, repeated processes, inputs and outputs.