Definition
Abstraction creates a simplified model that represents reality without capturing all of its complexities. In computer science, real-world entities and processes are often represented using abstract models such as tables, databases, or objects in object-oriented programming (OOP).
Representing Reality in Code
Worked Example
Objects in OOP vs Real World
The abstraction keeps the essentials for the task and omits unnecessary physical complexity.
| Real-world car detail | Included in simple Car abstraction? |
|---|---|
| Thousands of mechanical parts | No |
| Wear and tear history | No |
| Fuel and engine thermodynamics | No |
| Current speed/state | Yes |
| Actions like start/brake | Yes |
pseudocode
class Car:
private colour
private model
private speed
private isRunning
public procedure start()
public procedure accelerate(amount)
public procedure brake()
public function getSpeed()
end class
Worked Example
Variables and Data Structures
The array abstraction hides memory allocation and low-level storage mechanics.
| Real-world version | Abstract program model |
|---|---|
| Names on paper list | studentNames array/list |
| Re-order manually | studentNames.sort() |
| Add a new name manually | studentNames.add("Eve") |
| Count names manually | length(studentNames) |
pseudocode
studentNames = ["Alice", "Bob", "Charlie", "Diana"]
studentNames.sort()
studentNames.add("Eve")
count = length(studentNames)