What is abstraction? - Part 3
This article explains abstraction as choosing what matters for a purpose, comparing real-world views with billing, stock and delivery models for the same grocery item.
What is abstraction? - Part 3
Abstraction is the first principle of object-oriented thinking and, in my view, the most important one. Most of the beginners know it as “abstract class” or “interface” keyword, but the keyword is only a tool to write down an abstraction, it is not the abstraction itself. Long before computers, abstraction was how humans understood the world. A child uses it when he learns the word “dog”, a cartographer uses it when he draws a map, and a painter uses it when he draws a bull with a few lines. We use it every minute without noticing it, when we drive a car, use a mobile phone or switch on a fan. In the previous article, we discussed how we organize what we know, classification, generalization, specialization and hierarchy. In this article, we are going to see what is abstraction, first as a way of understanding the world, and then as a principle of object-oriented thinking, its types, levels of abstraction and how to find a good abstraction.
Object-Oriented Thinking series:
- How to model the real world with objects? - Part 1
- How do we organize what we know? - Part 2
- What is abstraction? (this article)
- What is encapsulation? - Part 4
- What is inheritance? - Part 5
- What are subtype and subclass polymorphism? - Part 6
- How objects relate to each other? - Part 7
- How all these concepts connect? - Part 8
TL; DR Summary
- Abstraction is focusing on the essential characteristics of a thing and ignoring the details which are not important for the purpose.
- In the real world, abstraction is generalization, simplification, finding the essence, identifying patterns and creating a model of reality, all at the same time.
- Every abstraction is a model, it is useful because it leaves things out.
- It is a way of thinking first, the abstract class and interface are just ways to write it in code.
- What is essential depends on the viewer, the same thing has different abstractions for different purposes.
- Data abstraction tells what an object is, behavioural abstraction tells what an object does, without telling how.
- We work at different levels of abstraction, a good design keeps each level clear and separate.
- Too little abstraction creates complex code, too much abstraction creates confusing code.
Common Challenges
Too many details
When we model an item, it is tempting to add everything we know about it, name, price, barcode, colour, weight, size, supplier, manufacturing date, factory address, shelf number. The object becomes huge, every part of the program depends on it and a change in any detail affects everyone. Hmm, a simple billing screen now needs to know the factory address of the rice!
Thinking about “how” too early
Beginners usually start with “how” questions, how to store the items, which loop to use, which database table. When we think about “how” first, the “what” gets mixed with it, and the design is tied to one way of doing things. Later, when the “how” is changing, for example, the price comes from a web service instead of a file, the whole design must be changed.
Abstraction in the real world and in philosophy
The word “abstract” comes from the Latin “abstrahere”, which means “to draw away” or “to pull out”. To abstract is to pull out the important part of something and leave the rest behind. Let us discuss the different faces of abstraction, one by one, without any computer.
Abstraction is generalization
In 1689, the philosopher John Locke described how a child forms general ideas. First, the child knows only particular people, his mother and his nurse. Slowly, he notices that many others look and behave like them, and he forms a general idea, “human”, by leaving out what is special to each person, the name, the face, the voice, and keeping only what is common.
This is the generalization we discussed in the previous article, and it is the first face of abstraction. Abstraction is creating a general concept from specific instances. “Dog” is an abstraction of all the dogs we have seen, no single dog is “dog”.
Abstraction is simplification
A map of Chennai doesn’t show every tree, every house and every pothole. If it did, it would be as big as Chennai and completely useless. A map is valuable exactly because it is simpler than the city. The philosopher Alfred Korzybski said it in a famous line, “the map is not the territory”. The map is an abstraction, it is not the real thing, but it is the right thing for finding the way.
It means, abstraction is ignoring the non-essential details on purpose. Leaving things out is not a weakness of an abstraction, it is the whole point of it.
Abstraction is finding the essence
Between December 1945 and January 1946, Pablo Picasso made a series of eleven lithographs called “The Bull”. The first one is a realistic bull with muscles, shading and hair. In each next print, he removed some details, and the last one is just a few simple lines. Still, everyone who sees it knows immediately, it is a bull. Picasso was searching for the essence of a bull, the minimum which still makes it a bull.
This connects to what we discussed in the previous article about Aristotle’s essential and accidental properties. The colour, the size and the shading of the bull are accidental, the shape of the horns and the body are essential. Abstraction is understanding the essence of something, the features without which it is not that thing anymore.
Abstraction is identifying patterns
An experienced doctor looks at a patient with fever, body pain and a rash and says “it looks like dengue”. He has not seen this patient before, but he has seen the pattern many times. He ignores the patient’s shirt, his job and his height, and focuses on the few features which form the pattern.
Pattern recognition, which we discussed as a pillar of computational thinking in Thinking Like a Programmer - Part 1, and abstraction are very close friends. We first notice the pattern in many cases, then we abstract it into a concept with a name, and from then on, we can recognize it in new cases.
Abstraction has levels
We can abstract an abstraction again. The linguist S. I. Hayakawa explained this with a “ladder of abstraction”, using a cow named Bessie. The following diagram depicts his ladder. At the bottom is Bessie, the real cow in the farm with all her details. Going up, she is a cow, then livestock, then a farm asset, then an asset and finally wealth. Each step up keeps fewer details and covers more things.

Notice that each level is useful for a different person. The farmer milks Bessie, the veterinary doctor treats cows, the bank manager is interested in the farm assets and the economist talks about wealth. Nobody is wrong, they are simply working at different levels of the ladder. Problems start only when people mix the levels, like an economist who talks about Bessie’s milk in a budget speech.
Abstraction is a model of reality
A globe, an architect’s model of a house, a weather forecast and a family tree are all models. Each one represents some part of reality for a purpose, and each one leaves out a lot. The statistician George Box said, “all models are wrong, but some are useful”. A model is wrong because it is not complete, it is useful because it is simple enough to think with.
Abstraction simplifies complex systems
In 1931, Harry Beck, an engineering draughtsman, designed a new map for the London Underground. Instead of showing the real distances and the curves of the tracks, he drew only straight lines, the stations and the connections, like an electrical circuit. Geographically, it was wrong. For a passenger, it was perfect, because the passenger only needs to know which line to take and where to change. Most of the metro maps in the world, including the Delhi Metro map, follow his idea.
This is how we handle very complex systems. Nobody can understand a whole city, a whole human body or a whole government at once. We understand them through abstractions, each one simple enough for the job in hand.
So, what is abstraction in real life?
Based on the above, find below the faces of abstraction we have seen,
- Generalization - Creating general concepts from specific instances (Locke’s child).
- Simplification - Ignoring the non-essential details (the map).
- Essence - Focusing on the essential features, the ones which make it what it is (Picasso’s bull).
- Patterns - Identifying what repeats in many cases (the doctor).
- Levels - Each abstraction can be abstracted again (Hayakawa’s ladder).
- Model - A useful, incomplete picture of reality (the globe).
- Managing complexity - Making a complex system understandable (the metro map).
These are not seven different things, they are seven views of the same mental act, deciding what matters for a purpose and pulling it out from everything else. Now, let us move to object-oriented thinking and see how this same act is used to design software.
What is abstraction in object-oriented thinking?
Abstraction is the process of identifying the essential characteristics of a thing which distinguish it from other things, relative to the perspective of the viewer, and ignoring all the other details.
In simple terms, abstraction is “keep what matters, hide what doesn’t”. Grady Booch, one of the well known authors of object-oriented design, explains abstraction as the essential characteristics of an object that give it clear boundaries, from the viewer’s perspective. The two key words are “essential” and “viewer”, the same essence of Picasso and the same purpose of the map.
Let us take the car as an example. For the driver, a car is a steering wheel, accelerator, brake and gear. He doesn’t need to know how the fuel injection is working inside the engine to drive. For the mechanic, the same car is an engine, gearbox, brakes and electrical system. Both are correct abstractions of the same car, for two different purposes.
Same thing, different abstractions
The essential details are not a property of the thing, it depends on why we are looking at it. The following diagram depicts the same rice packet from three different views in our shop. The real packet has many details, each view keeps only the few which matter for its purpose and ignores the rest.

- Billing view - Name, price and barcode. That is all the billing counter needs.
- Stock view - Barcode, stock quantity, shelf and supplier, to know when to reorder and from whom.
- Delivery view - Weight, size and package type, to plan the space in the delivery van.
Notice that the barcode is in two views, but the brand, the packet colour and the manufacture date are not in any view. They are real details of the packet, but none of these purposes need them.
It means, there is no single “correct” Item object for the whole world, the same way there is no single correct map of Chennai. If we try to create one Item which satisfies all three views, we are back to the “too many details” challenge. It is important to ask “who is going to use this object and for what?” before deciding its details.
Types of abstraction
Data abstraction
Data abstraction is describing what an object is through its essential information, without exposing how that information is stored.
For the billing counter, an item “has a price”. Whether the price is stored as a number, calculated from the price per kg or fetched from the head office is not the concern of the counter. It just knows “I can ask the item for its price”.
Behavioural abstraction
Behavioural abstraction (also called procedural abstraction) is describing what an object can do, without telling how it is done.
When we press the “Call” button in a mobile phone, the call is connected. We don’t know how the phone finds the tower, how the voice is converted into signals and so on. We only know the behaviour “make a call to this number”. Similarly, the bill offers “give me the total”, the screen which shows the total doesn’t know whether the bill adds each line or applies five different discount rules, it only trusts the bill to give the correct total.
Levels of abstraction
Like Hayakawa’s ladder, we don’t think about a system at one level only, we zoom in and zoom out. Here are the levels in our shop, from high to low,
- Shop - Sells items to customers.
- Billing - Creates a bill, adds items, calculates the total, takes payment.
- Bill - Holds the bill lines and knows the total.
- Bill line - Knows one item, its quantity and its amount.
- Number arithmetic - Multiply and add in decimal.
Each level uses the level below it without knowing its details. The shop owner thinks at level 1, the developer of the billing module thinks at level 2 and 3. Problems start when the levels are mixed, for example, a method which calculates the discount and in the same place opens a database connection and formats the printer output. It is mixing high-level business thinking with low-level technical details, and it is very hard to read and change.
Must Consider: Keep one level of abstraction in one place. A business object like Bill should talk in business terms (items, total, discount), not in technical terms (SQL, file path, printer port).
How to find a good abstraction?
Find below few guidelines to evaluate an abstraction,
- One clear purpose - It should represent one concept. If you need the word “and” to explain it (“Item and Stock and Supplier”), it is probably more than one abstraction.
- Name from the domain - Use the words the business uses, Bill, Item, Discount, not Manager, Helper or Data.
- Minimal - Keep only the details which the users of the abstraction really need. It is easy to add later, but very hard to remove once everyone depends on it.
- Stable - The essential details should rarely change. Price is essential for billing, the printer model is not.
- What, not how - It should describe what it is and what it does, the how is the internal matter.
Leaky abstraction
Sometimes an abstraction cannot hide all the details and the hidden details “leak” out. Joel Spolsky wrote about this as “The Law of Leaky Abstractions” in 2002, all non-trivial abstractions, to some degree, are leaky. For example, the price may come from the head office server, and when the network is slow, the billing counter becomes slow, the counter now has to know something about the network. Keep in mind that leaks will happen, as George Box said, every model is wrong somewhere. A good design accepts that and handles them at the right level, like showing a “price not available” message instead of freezing the counter.
Too much abstraction
On the other hand, too much abstraction is also a problem. Remember Picasso’s last bull, if he had removed one more line, it would not be a bull anymore. Creating many layers and generic objects “just in case” makes the design hard to understand, the reader has to open five files to find one simple calculation. Start with the abstractions the problem really needs, and introduce new ones only when there is a real need.
Abstraction vs the code
So far, we didn’t write a single line of code, and that is intentional. Abstraction happens in our mind first, while understanding the problem, the same way it happened for Locke’s child and for Harry Beck. Abstract classes and interfaces in Java and C# are only the tools to write down the abstraction we have decided, so that the compiler can enforce it. A program can use interfaces everywhere and still have poor abstractions, and a program with very few interfaces can have very clear abstractions. We will see how interfaces are used for polymorphism in Part 6.
Wrap up
In this article, we have looked at abstraction in the real world and in philosophy, as generalization, simplification, essence, patterns, levels and models, and then as a principle of object-oriented thinking, the same thing with different abstractions, data and behavioural abstraction, levels of abstraction and how to find a good abstraction. I appreciate your time and efforts to read this article. Abstraction decides what the outside world should see, but it doesn’t protect what is inside. In the next article, I will walk you through encapsulation, first as responsibility and trust in the real world, and then how an object protects its state and why it is not the same as just making the fields private.
Related Posts
How all these concepts connect? - Part 8
This final article connects the three series, showing how real-world problems, computational thinking and object-oriented principles form one practical mental model for designing software with a grocery shop example.
How do we organize what we know? - Part 2
This article explains classification, generalization, specialization and hierarchy, showing how programmers organize grocery items and discover common concepts before designing software models for beginners today.
How to model the real world with objects? - Part 1
This article introduces object-oriented thinking by modeling a grocery shop as customers, items and bills, then explains objects through identity, state, behaviour and classes for beginners.