How to Form Abstractions: A Guide for Getting Abstract with Computational Thinking

April 21, 2023

jarednielsen abstraction

Thinking like a programmer means thinking like a computer. If you want to think like a programmer, you’ll want to learn computational thinking.

There are four stages of computational thinking:

  • Decomposition

  • Pattern recognition

  • Abstraction

  • Design

In this article, we’ll get abstract with the third stage of computational thinking.

If you’re just joining us, you may want to check out the first article in this series, How To Break a Problem Down: A Guide for Using Decomposition in Computational Thinking.

What is abstraction?

According to Werner Heisenberg, the process of forming abstractions is “…the possibility of considering an object or group of objects under one viewpoint while disregarding all other properties of the object.”

He continues:

The essence of abstraction consists in singling out one feature, which, in contrast to other properties, is considered to be particularly important.

Abstracting is an essential problem-solving skill in that it enables us to “see the forest for the trees”. It’s also essential for learning new concepts and skills.

In A Mind for Numbers, Barbara Oakley refers to the process of forming abstractions as chunking, and defines chunks as “…pieces of information that are bound together through meaning”. She continues:

You can take the letters p, o, and p and bind them into one conceptual, easy-to-remember chunk, the word pop. It’s like converting a cumbersome computer file into a zip file. Underneath that simple pop chunk is a symphony of neurons that have learned to trill in tune with one another. The complex neural activity that ties together our simplifying, abstract chunks of thought—whether those thoughts pertain to acronyms, ideas, or concepts—are the basis of much of science, literature, and art.

And programming!

In Code Complete, Steve McConnell offers his own definition:

Abstraction is the ability to engage with a concept while safely ignoring some of its details—handling different details at different levels. Any time you work with an aggregate, you’re working with an abstraction.

“Construction” is McConnell’s favorite metaphor for software development, and he offers this analogy to illustrate abstraction:

If you refer to an object as a “house” rather than a combination of glass, wood, and nails, you’re making an abstraction. If you refer to a collections of houses as a “town”, you’re making another abstraction.

According to the authors of Sparks of Genius:

Abstracting, then, is a process beginning with reality and using some tool to pare away the excess to reveal a critical, often surprising, essence. Artists do it; writers do it; scientists, mathematicians, and dancers do it. And they all do it in the same basic way. You can, too.

Why do we form abstractions?

We all form abstractions without even knowing it. They become our heuristics, or mental models, as well as our biases. The key to success in problem-solving, programming, and lifelong learning is to develop metacognition, to improve our thinking about thinking.

According to the authors of Sparks of Genius, “learning how to abstract in one discipline provides the key to understanding the abstractions of all disciplines.” They continue:

When an artist invents a new method for abstracting, scientists and technologists benefit, and when a scientist or engineer discovers another form of abstraction, artists may hurry to employ it. Every scientific experiment, every scientific theory, is just as much an abstraction as an abstract painting or poem. Scientist, artist, and poet alike all strive to find meaning in complex systems by eliminating every variable save one. Experimentation in science, like that in the arts, becomes a formalized process for discovering important abstractions.

Not only does abstraction improve your problem solving skills, it changes the shape of your brain! Now that’s meta! This is especially important if we are working with formal languages, which are, well, not natural.

How do we change our brains?

Practice.

According to Barbara Oakley in A Mind for Numbers:

It seems people can enhance the development of their neuronal circuits by practicing thoughts that use those neurons. We’re still in the infancy of understanding neural development, but one things is becoming clear—we can make significant changes in our brain by changing how we think.

We make these changes through forming abstractions, or, in Oakley’s terms, chunking:

Good chunks form neural patterns that resonate, not only within the subject we’re working in, but with other subjects and areas of our lives. The abstraction helps you transfer ideas from one area to another.

The authors of Make It Stick distinguish between two types of intelligence which encapsulate this process of chunking and changing:

  • fluid

  • crystallized

Fluid intelligence is “the ability to reason, see relationships, think abstractly, and hold information in mind while working on a problem.”

Crystallized intelligence is “one’s accumulated knowledge of the world and the procedures or mental models one has developed from past learning and experience.”

According to Brown et al, “…together, these two kinds of intelligence enable us to learn, reason, and solve problems.”

In Code Complete, Steve McConnell defines Software’s Primary Technical Imperative as managing complexity. To aid us in this goal, he outlines several design building blocks, or heuristics, one of which is to Form Consistent Abstractions. In terms of object-oriented programming, this means that “a good class interface is an abstraction that allows you to focus on the interface without needing to worry about the internal workings of the class.” He continues:

From a complexity point of view, the principal benefit of abstraction is that it allows you to ignore irrelevant details. Most real-world objects are already abstractions of some kind. As just mentioned, a house is an abstraction of windows, doors, siding, wiring, plumbing, insulation, and a particular way of organizing them. A door is in turn an abstraction of a particular arrangement of a rectangular piece of material with hinges and a doorknob. And the doorknob is an abstraction of a particular formation of brass, nickel, iron, or steel. People use abstraction continuously. If you had to deal with individual wood fibers and varnish molecules and steel molecules every time you used your front door, you’d hardly make it in or out of your house each day.

Forming abstractions is particularly important in programming because “…software developers sometimes build systems at the wood-fiber, varnish-molecule and steel-molecule level. This makes the systems overly complex and intellectually hard to manage. When programmers fail to provide larger programming abstractions, the system itself sometimes fails to make it through the front door.”

How do we improve our abstracting ability?

How do we form abstractions?

According to the authors of Sparks of Genius, “it’s never too late or too soon to start abstracting.” The Root-Bernstein’s outline these steps:

  • Inspire yourself by collecting examples of abstraction by the masters.

  • Imitate.

  • Test your progress by abstracting some object such as an orange or a human being over and over again.

And, perhaps, most importantly:

  • Don’t just look—think! Find the surprising properties hidden behind the obvious ones. See with your mind, not your eyes.

You can test yourself by asking the following questions:

  • What abstractions have you discovered that you overlooked before? Orange juice? The heart’s beat? A list of chemical constituents?

  • Can you refine these and other abstractions even further than you first thought, engaging in an abstract process over time?

Practice makes practice. “There are no ‘right’ answers to these questions. only a never-ending quest for greater simplicity and more profound truths. Ultimately, what matters is finding the essence of abstraction itself to light your way wherever you explore.”

According to the authors of Make It Stick, “…by abstracting the underlying rules and piecing them into a structure, you go for more than knowledge. You go for knowhow. And that kind of mastery will put you ahead.” They also provide a series of steps improve your ability to form abstractions:

  • Be the one in charge. Mastery, especially of complex ideas, skills, and processes, is a quest. It is not a grade on a test, something bestowed by a coach, or a quality that simply seeps into your being with old age and gray hair.

  • Embrace the notion of successful intelligence. Go wide: don’t roost in the pigeonhole of your preferred learning style but take command of your resources and tap all of your “intelligences” to master the knowledge or skill you want to possess. Describe what you want to know, do, or accomplish. Then list the competencies required, what you need to learn, and where you can find the knowledge or skill. Then go get it.

  • Adopt active learning strategies like retrieval practice, spacing, and interleaving. Be aggressive. Don’t rely on what feels best: like a good pilot checking his instruments, use quizzing, peer review, and other tools to make sure your judgment of what you know and can do is accurate, and that your strategies are moving you toward your goals.

  • Distill the underlying principles; build the structrure. Break your idea or desired competency down into its component parts. If you think you are a low structure-builder or an example learner trying to learn new material, pause periodically and ask what the central ideas are, what the rules are. Describe each idea and recall the related points. Which are the big ideas, and which are supporting concepts or nuances? If you were to test yourself on the main ideas, how would you describe them? What kind of scaffold or framework can you imagine that holds these central ideas together?

As we saw above, abstracting will also make you a strong programmer. According to Steve McConnell in Code Complete

Good programmers create abstractions at the routine-interface level, class-interface level, and package-interface level—in other words, the doorknob level, door level, and house level—and that supports faster and safe programming.

A Guide for Getting Abstract

In computational thinking, abstraction is the process of generalizing attributes. We form abstractions in order to focus on the relationships between concepts rather than their details. We can improve our ability to form abstractions through study, practice, and, most importantly, through asking ourselves, “How can this be improved?“. In the next article, we’ll look at how the fourth and final stage of computational thinking: algorithm design, AKA pattern forming. Stay tuned!


Profile picture

Want to level up your problem solving skills? I write a bi-weekly newsletter about programming, problem solving and lifelong learning. Join now