Lessons‎ > ‎


Topic: What is Abstraction?

Objectives:  Students will be able to:
  • Understand the concept of an abstraction.
CS Principles Learning Objectives: Students will be able to:
  • 2.1.1 Describe the combination of abstractions used to represent data. [P3]
Essential Knowledge: Students need to know:
  • 2.1.1.a Abstractions are used to represent data.
  • That aabstraction is a general representation or concept or idea  that stands for some collection of individual instances.
  • Lesson Starter (3 minutes): What does 'chair' mean? What does 'rectangle' mean?
  • Explanation (1 minutes): 'Chair' and 'rectangle' are both abstractions.
  • Lecture (8 minutes): What is an abstraction? What are the types of abstractions? Why is abstraction important?
  • Wrap up (3 minutes): Interactive exercises
  • Lesson Starter: Ask each student to take a piece of paper and without talking communicate to the class what 'chair' means. Students may use words, phrases, pictures, etc but they cannot talk. When the students are finished have the students hold up their papers to show the entire class. Next, ask the students to do the same thing for 'rectangle'. What do the students notice about what they have put on their papers?
  • Explain: All of the students' answers are correct. This is because 'chair' and 'rectangle' are both abstractions
    • Abstraction can be looked at in two ways, as a practice or a habit of mind, sometimes called abstracting.  And as a particular thing, such as an idea or a word where we say, for example, that the word 'chair' is an abstraction. The words 'chair' and 'rectangle' represent an idea of something. 
    • We refer to anything that we can sit in as a 'chair'. But, there are different kinds of chairs (e.g. desk chairs, office chairs, wooden chairs, rolling chairs, etc.) When we say 'chair' we can mean any one of these.
    • Any shape that has 4 sides, with opposite sites of equal length, is a 'rectangle'. But, there are different kinds of rectangles (e.g. 4x6 rectangles, 2x6 rectangles, 3x9 rectangles, etc) When we say 'rectangle' we can mean any one of these.
  • Lecture: Use this presentation to give a brief explanation of abstraction with some examples. Explain to students that aabstraction is a general representation or concept or idea  that stands for some collection of individual instances. Abstractions can be found in language, design, maps, and computer science. The students will learn variables, procedures, and data abstraction while in the course. In the next lesson, the students will begin learning data abstraction which includes bits and binary numbers. Feel free to use any of the talking points below. Words in bold are good pieces of information to note/explain during this lecture.
    • First, let’s think about abstraction as a practice.  As mental agents we are constantly bombarded through our senses by sensations  -- i.e., sights and sounds and tactile sensations.   Somehow our brains condense these raw data into simple recognizable constructs that we can use to function in the world.   For example, when I look out the window, I recognize various objects – trees, birds, and flowers – that my brain has constructed for me out of the raw signals (light waves) that come in through my eyes.  It requires no mental effort on my part to see a tree.  Similarly, our ability to give names to things – the word ‘tree’ – and then use the names in our language and thought is good example of abstracting as a habit of mind.

      Thus, as a practice or habit of mind, abstracting is the process of simplifying or condensing large amounts of data into manageable chunks.  We have various names for these chunks depending on how they are used – e.g., ideas, concepts, words, and so on.  But in this sense abstracting is a fundamental element of human cognition and language.  We could neither think nor speak if our brains couldn’t create abstractions.  

      Let’s now think about the result of this abstracting process – the ideas and concepts and words that we manipulate in our everyday thought and language.  An abstraction in this sense is general representation that stands for some complex collection of individual instances.   One of the main characteristics of an abstraction is that it simplifies a complex phenomenon by leaving out the irrelevant aspects. When our brain creates the perception of a tree, it ‘abstracts away’ many of the details, its color, its species, its height and so on.  Of course what is ‘irrelevant’ only has meaning in a certain context.  For a botanist, a tree’s species is very important so perhaps when a botanist sees a tree, he or she always sees an oak tree or a maple tree. Most of us just see a tree. 

      One of the main characteristics of an abstraction is that when viewed from the perspective of an individual instance, it leaves out certain non-essential details.  In creating an abstraction we 'abstract away' certain details of the instances we're trying to represent.  This 'abstracting away' is a fundamental habit of mind, a low-level feature of human cognition and language.  We could neither speak nor think if we weren't able to create and manipulate abstractions.  
      In order to understand and use an abstraction, we need to understand the context in which it is used.  Here are some everyday examples.

      Language example:  A definition of any word we use in our language -- e.g., 'chair' -- is an abstraction.  When we define 'chair' -- or cognitively think of a chair -- we don't think of its color or what type of material its made of. The word or idea is a general representation of chairs.  A name is sort of the ultimate abstraction. It's just a simple symbol that represents an individual.  Imagine what life and language would be like if we had to give a detailed description every time we wanted to refer to someone?

      Design example:  If you were remodeling your kitchen you might create a schematic model of the floor plan with rectangles or squares to represent the size and location of the appliances.  The model is a general representation of an actual kitchen and its appliances.  Among other things, we've 'abstracted away' the brand and color of the appliances and the entire Z-axis, if we're doing this in a 2-d model (bird's eye view).

      Map example:  Think of a hand-drawn map.  It's a general representation of some particular geographical region in which we've abstracted away the actual dimensions, foliage, etc. The abstraction contains just those details that we need to get us from point A to point B.

      What does this have to do with the study of computer science?   In computer science the process of abstracting – simplifying, condensing, encapsulating – is an important problem solving technique that is used in designing computer systems from the lowest levels of the hardware to the highest levels of the software.  And, as we will see in this course, computer scientists constantly strive to create abstractions, in hardware and software, that help reduce complexity and make computer systems and computer programs easier to use and understand

      In this course we will deal with two main types of abstraction, data abstraction and procedural abstraction. Here are a couple of brief examples.

      Data Abstraction.  In a computer program a variable is named section of memory, e.g., ‘X’, that can store a piece of data – i.e., a number or a word or a list of objects. When we want to manipulate the data, we can use its name rather than the data itself.  So the name, the variable, is an abstraction of the data stored in the variable.  Using the name, rather than the data itself, simplifies things for the programmer, especially because the data stored in the variable can change.

      There’s another sense in which the variable is an abstraction. First, inside the computer’s memory, everything is stored as electronic signals, on or off, high voltage or low voltage.  It’s hard to see electronic signals or write them on a piece of paper.  So computer scientists represent those electronic signals as bitsbinary digits – i.e., 0s and 1s. So bits are a higher-level of abstraction and, as such, easier for us to deal with.  But strings of bits – 000100010100010 – are relatively hard for most people to manipulate.  We prefer to deal with higher-level symbols, such as decimal numbers (5) and words (tree) and lists of numbers ([1,2,3,4,5]). These then, are higher-level abstractions that make it easier for us to manipulate data. [There are different levels of abstraction, for example, using words vs. using pictures vs. using bits (where words are at the highest level - the easiest for us to understand- and bits are at a lower level.) The next abstraction lesson Adding 1+1=2 covers this in more detail by explaining to students how a computer adds 1+1.)] Finally, because these data can change within the computer’s memory, we use variables to achieve an even higher level of abstraction.  In effect, the variable lets us say ‘take whatever data are stored in X and put it in Y.’

      Procedural Abstraction.  procedure is a named chunk of code that performs a particular task.  An example might be the square root procedure, which calculates the square root of X, sqrt(X).  The nice thing about procedures is that they hide the details of how they carry out their task.  For example, we may no longer remember how to calculate a square root by hand, but we do know how to use the sqrt() procedure (on a computer or a calculator) to calculate the square root of any number:  I simply call it and give it the number.  So sqrt(4)  is 2. And sqrt(5) is 2.236. 

      The sqrt() procedure is an abstraction. It encapsulates a complex task and gives us the ability to perform that task without worrying about the details of how it works. It ‘abstracts away’ the details of how to calculate a square root.   And just like with data abstraction, procedures can be organized into levels of abstraction.  For example, if you remember your Pythagorean theorem you will recall that the “length of the hypotenuse of a right triangle is the square root of the sum of the squares of the other two sides.”  So, once we have low-level procedures, such as sqrt(X), we can use them to define higher-level procedures such as hypotenuse(a,b).  Then to calculate the hypotenuse of a 3-4-5 right triangle, we can just call hypotenuse(3,4)  and it will give us the value 5. 

  • Wrap up: Complete the interactive exercises as a class.
Notes for Teacher:

In this course we will see many examples of abstraction throughout our study of computer science. In the very next lesson, Binary Numbers, the students will learn about binary numbers and binary counting.

Reflection for the Teacher (Learn Adapt Teach Reflect):

  1. Is there anything else you would need to have or know to teach this lesson effectively?
  2. What specific elements of this lesson (examples, activities, etc.) would you change?

  3. How would you modify or add to the interactive exercises (formative assessments)?

Related Resources and Activities:

Suggested resources TBD