GCSE Link: 1.01 - Computational Thinking

Abstraction is a process used in Computer Science where we remove details to focus on the important parts of a problem.

There are many different types of abstraction, which we will cover on this page:


Representational abstraction is about removing unnecessary details of a problem.

For example, if you were writing a program to find the shortest route between two places, you don't need details such as the names of specific buildings and parks, so you would use representational abstraction to just focus on the roads.

Information hiding is a form of representational abstraction - other classes only need to know the essential characteristics of an object, and not any protected or private attributes.


Abstraction by generalisation is about grouping together objects with common characteristics.

This allows us to simplify problems. An example of this is inheritance in OOP, where subclasses can use methods implemented in the parent class (so you don't need to write them twice).


Procedural abstraction is about using a general method (procedure) to complete a repeated task.

For example, when making a game, you might write a drawText(message) procedure to draw some text (given in the parameter message) on the screen. Once you've written it, you can forget about doing those exact steps again, and instead just call the procedure.


Functional abstraction takes procedural abstraction one step further and hides the method of computation itself.

Do you know how the square root (sqrt) function actually works? (If you're interested, check out the Wikipedia article.) This is an example of functional abstraction - the user doesn't need to know how it works, just that it works.


Data abstraction is about hiding the implementations of abstract data types.

If a programming language has a stack data type, you don't need to know how it's actually implemented under the hood (similar to functional abstraction, just for data types).


Problem abstraction is about reducing the problem to one which you have already solved.

For example, if you were writing a program to find a route between two Tube stations, you could represent the map as a graph, with stations being nodes and lines being edges. Then you could traverse the graph as usual to find a route.



How might abstraction be used when calling a weather API?

Representational abstraction is used, because only the relevant details (temperature, wind, etc.) are returned by the API, and not the raw data collected by weather balloons. Functional abstraction is also used, because the user doesn't know how the forecast actually works.