2 Computational thinking and abstraction
In the next activity you will see Wing explain how computational thinking involves the process of abstraction.
Activity 3 Abstraction
Watch the video and then complete this activity.
Transcript: Abstraction
Computational thinking is all about the process of abstraction. Let me explain what I mean by that. First of all, it is choosing the right abstraction. Not every abstraction is going to be appropriate for the problem you are trying to solve. So first you choose an abstraction and then by definition of abstraction are ignoring irrelevant detail and encapsulating in this abstract model the details of importance. That means I’m immediately talking about at least two levels of interest. The level I am ignoring the detail from and the level of interest so the abstraction process immediately means that you are talking about at least two levels of abstraction, and in fact the way in which computer scientists deal with scale and complexity in the kind of artefacts that we build and design is through layers of abstraction. That allows us to focus at each layer only on the properties or behaviours of interest and then we build these complex systems by layering or other means of composition. So when we talk about abstraction it’s not just the abstraction or the particular model. It’s the layers and also the relationships between the layers and because we usually define these abstract models in very precise terms, mathematical terms, we are able to define the relationships between these layers also precisely in mathematics. In fact all of what I said is as we do in mathematics. After all it is not that computer scientists invented abstraction. Mathematicians and scientists use abstractions all the time. What’s different is that in computing we are always operating at least two layers of abstraction at the same time and we are very formal about the relationship between the two layers.
Wing talks about abstractions as a means of ignoring detail that is not of interest. Consider the following description of an algorithm for searching a paper and ink dictionary.
Given:
- i.a dictionary
- ii.a headword W which appears in the dictionary
to find the definition of W:
- Begin the search with an entry that appears (roughly) in the middle of the dictionary. Then there are three possibilities:
- The current entry’s headword is W. In this case, the definition of W is the definition of the current entry.
- W appears alphabetically before the current entry’s headword. In this case, the entry with headword W must appear in the first half of the dictionary. Look for the word W, following the same approach, in the first half of the dictionary.
- W appears alphabetically after the current entry’s headword. In this case, the entry with headword W must appear in the second half of the dictionary. Look for the word W, following the same approach, in the second half of the dictionary.
This is an informal description of an algorithm, but the steps are sufficiently precise that a human should have no problem following them. This algorithm depends crucially on the fact that the words in a dictionary are alphabetically ordered. It also, however, ignores some of the details of paper and ink dictionaries. Can you list of few of these?
Discussion
Details of a paper and ink dictionary that come to mind include: the size and thickness of its pages, the colour of its cover and the size of the printed font. None of these played a role in the algorithm that is described above. Perhaps the most salient abstraction relates to the fact that paper and ink dictionaries are made of pages. They are not simply a list of words and definitions. Rather, the words are distributed across the pages of the dictionary. The algorithm doesn’t take into account the distribution of the words in a dictionary across pages: for example it would work equally well with a dictionary printed on a single, enormously long paper scroll.
Wing’s discussion of abstraction draws on a wide variety of concepts. You have come across phrases such as ‘ignoring’ and ‘hiding information’, ‘levels’ and ‘layers’, ‘models’ and ‘implementation’. It has been left somewhat in the air how these all hang together. So next, we will make the relations between them explicit. To do so, we will distinguish between two kinds of abstraction:
- abstraction as modelling
- abstraction as encapsulation.
Although Wing deals in great detail with the idea of abstraction as modelling, she only hints at the concept of abstraction as encapsulation. Both are, however, at play in computing. Distinguishing between them will give you a better understanding of the remainder of Wing’s story.