4.1 Abstraction and Abstraction Hierarchies
Key Takeaways
- Abstraction reduces complexity by hiding details that are not needed at the current level and exposing only what is essential.
- From lowest to highest abstraction: transistors, logic gates, circuits and processors, machine language, assembly language, high-level text languages, block-based languages and applications.
- Machine language (binary instructions) is a lower level of abstraction than assembly language, which gives those instructions readable mnemonics.
- Procedures, data types, APIs, files, and graphical interfaces are all abstractions: each lets you use something without knowing how it works inside.
- Generalizing a solution means removing specific details, for example by replacing hard-coded values with parameters, so that one solution handles a whole family of problems.
Why abstraction is the foundation
ETS begins the Algorithms and Computational Thinking category with abstraction as a foundation of computer science. You are asked to:
- Identify, create, or complete the correct ordering, from low to high, of an abstraction hierarchy.
- Identify abstractions in context.
- Identify details that can be removed from a solution in order to generalize it.
An abstraction is a simplified representation that hides details you do not need at the moment. When you press the brake pedal, you use an abstraction of the braking system. When you call sort ( list ), you use an abstraction of a sorting algorithm. A good abstraction lets you think about what something does without knowing how it does it.
The layers of a computing system
Computer science is built as a stack of abstractions. Each layer uses the layer below it and hides that layer's complexity from the layer above.
| Level (low → high) | What lives here | What it hides |
|---|---|---|
| 1. Transistors and physics | Electronic switches, voltages | Semiconductor physics |
| 2. Logic gates | AND, OR, NOT, NAND built from transistors | How transistors switch |
| 3. Circuits and components | Adders, registers, memory cells, the ALU | Gate-by-gate wiring |
| 4. Processor (architecture) | The instruction set a CPU executes | Circuit layout |
| 5. Machine language | Binary instructions, such as 10110000 01100001 | Circuit-level operation |
| 6. Assembly language | Mnemonics such as MOV, ADD, JMP that map almost one-to-one to machine instructions | Binary encoding |
| 7. High-level text languages | Python, Java, C++, the ETS pseudocode | Registers and instruction details |
| 8. Libraries, APIs, and system software | sort, print, file and network calls | Algorithm and device details |
| 9. Block-based languages and applications | Scratch, Snap!, spreadsheets, browsers | Nearly all programming syntax |
ETS's sample question on this topic lists four items: assembly language, block-based programming language, logic gate, and machine language. It asks for the order from highest to lowest abstraction. The answer is block-based language, assembly language, machine language, logic gate. The common trap is placing machine language above assembly. Machine language is closer to the hardware, so it is lower.
Read the direction carefully. Some questions ask "low to high" and others "high to low," and the answer choices usually include the reversed order.
Other hierarchies you may be asked to order
| Hierarchy | Low → high |
|---|---|
| Data | bit → byte → number or character → string or array → record or object → file → database |
| Program structure | statement → block → procedure → class or module → library → application |
| Networks (Section 16.2) | physical signals → frames → packets → segments → application messages |
| Storage | disk sectors and blocks → files → folders → file system |
Identifying abstractions in context
When a stem asks which feature is an abstraction, look for something that gives a name to complexity so you can use it without the details.
| Abstraction | What it hides | Example |
|---|---|---|
| Procedure (procedural abstraction) | The steps inside | average ( scores ) returns the mean; the caller never sees the loop |
| Variable | A memory address | score instead of a numeric address |
| Data type | Bit-level representation | String, double, boolean |
| Data structure / abstract data type | How storage is arranged | A queue's enqueue and dequeue operations, whatever the implementation |
| API | A library's implementation | A weather API returns a forecast without revealing its models |
| File | Physical disk blocks | "report.docx" instead of block numbers |
| Graphical user interface | Commands and system calls | A "Save" button |
| Model or simulation | Real-world detail | A traffic model that ignores car color |
Numbers, characters, and colors are themselves abstractions over bits. The same eight bits can be read as the number 65, the character 'A', or one channel of a color. Chapter 13 covers these representations.
Removing details to generalize a solution
A solution becomes more general when you remove details that are specific to one case. The most common method is parameterization: replacing a hard-coded value with a parameter.
A specific procedure that works for only one case:
void drawSquare50 ( )
for ( int i ← 0; i < 4; i ← i + 1 )
forward ( 50 )
turn ( 90 )
end for
end drawSquare50
A generalized procedure that works for any regular polygon:
void drawPolygon ( int sides, int length )
for ( int i ← 0; i < sides; i ← i + 1 )
forward ( length )
turn ( 360 / sides )
end for
end drawPolygon
Two details were removed: the fixed side length (50) and the fixed number of sides (4, with its 90-degree turn). Now drawPolygon ( 4, 50 ) draws the original square, and drawPolygon ( 6, 20 ) draws a hexagon.
When a stem asks which detail can be removed to generalize, pick the detail that is specific to one instance and not essential to the task, such as a particular number, name, color, or location. Keep the steps that every instance needs. In a school-bus routing problem, for example, you can ignore the color of the buses and the drivers' names. You cannot ignore the road connections and travel times.
Choosing the right level
Too little abstraction buries you in detail. A teacher explaining loops does not start with transistor voltages. Too much abstraction hides details that matter. A performance problem may require you to look below the procedure call to see that it contains a nested loop. Skilled problem solvers move up and down the hierarchy as the question requires.
Which list is ordered from lowest level of abstraction to highest?
A procedure computes shipping for orders sent only to one city, using that city's fixed rate of 0.07 written directly in the code. Which change best generalizes the procedure for all cities?
A student's program calls getForecast ( zipCode ) from a weather service and displays the result without knowing how the service computes forecasts. What does this best illustrate?