You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Abstraction is one of the most fundamental concepts in Computer Science. It is the process of removing unnecessary detail to focus on what is important for solving a particular problem. The OCR H446 specification requires you to understand representational abstraction, abstraction by generalisation, information hiding, and levels of abstraction.
Abstraction means filtering out the details that are not relevant to the problem at hand, while keeping the information that is essential.
| Concept | Detail |
|---|---|
| Abstraction | The process of removing unnecessary detail to focus on the relevant aspects |
| Purpose | To simplify complex systems and make them manageable |
| Result | A model or representation that captures the essential features |
Everyday example: A map of the London Underground is an abstraction. It shows stations and connections but removes geographical accuracy, building locations, street names, and terrain. The details removed are irrelevant to the problem (navigating the tube network).
Representational abstraction involves removing unnecessary details from a problem to create a representation that captures only the essential features.
Examples:
| Real-world situation | Abstraction | Details removed |
|---|---|---|
| Weather forecast | Temperature, wind speed, precipitation probability | Exact atmospheric pressure at every point, molecular composition of air |
| Road map | Roads, cities, distances | Individual buildings, tree locations, road surface type |
| Database record of a student | Name, ID, grades | Shoe size, favourite colour, breakfast preferences |
| A variable in code | Name and value | Physical memory address, binary representation |
The key question in representational abstraction is: what details are relevant to this problem, and what can be safely ignored?
Key Term: Representational abstraction is about deciding what to include and what to exclude from a model or representation.
Abstraction by generalisation (also called categorisation) involves recognising that multiple problems share common features and grouping them together. This allows you to create a single solution that applies to many cases.
Examples:
| Specific problems | Generalisation | General solution |
|---|---|---|
| Sorting names, sorting numbers, sorting dates | All are sorting problems | A general sorting algorithm (e.g., merge sort) |
| A cat, a dog, a horse | All are animals | An "animal" class in OOP with shared attributes (name, age, weight) |
| Printing to a laser printer, inkjet printer, 3D printer | All are printing operations | A general "print" interface |
Abstraction by generalisation is the foundation of:
Information hiding means concealing the internal details of a component and exposing only what is necessary for other components to interact with it.
| Concept | Detail |
|---|---|
| Encapsulation | Bundling data and methods together and restricting access to the internal state |
| Interface | The visible part that other components interact with |
| Implementation | The hidden internal workings |
Example: When you use a function like sort(myList), you do not need to know whether it uses merge sort, quick sort, or another algorithm internally. The implementation is hidden; you only need to know the interface (pass in a list, get back a sorted list).
Benefits of information hiding:
| Benefit | Explanation |
|---|---|
| Reduced complexity | Users only need to understand the interface, not the implementation |
| Easier maintenance | Internal implementation can change without affecting other components |
| Fewer bugs | Other components cannot accidentally modify internal state |
| Better teamwork | Different team members can work on different components independently |
Complex systems are often structured in layers, each providing a different level of abstraction.
The computer system abstraction layers:
| Level | Layer | Detail visible |
|---|---|---|
| 5 (highest) | Application software | User interface, features |
| 4 | High-level programming language | Variables, functions, objects |
| 3 | Assembly language | Registers, mnemonics, memory addresses |
| 2 | Machine code | Binary instructions, opcodes |
| 1 | Logic gates / hardware | Voltages, transistors, clock signals |
| 0 (lowest) | Physics | Electron flow, electromagnetic fields |
Each layer hides the complexity of the layers below it. A Python programmer does not need to understand transistor physics; a user of Microsoft Word does not need to understand Python.
The networking abstraction layers (TCP/IP model):
| Layer | Name | Examples |
|---|---|---|
| 4 | Application | HTTP, FTP, SMTP |
| 3 | Transport | TCP, UDP |
| 2 | Internet | IP, ICMP |
| 1 | Network access | Ethernet, Wi-Fi |
Each layer communicates only with the layers directly above and below it.
When approaching a new problem, abstraction helps you:
Worked Example:
Problem: Design a system to manage a school library.
Step 1 — Identify relevant entities: Books, members, loans.
Step 2 — Decide what details to include for each entity:
| Entity | Relevant attributes | Irrelevant attributes |
|---|---|---|
| Book | ISBN, title, author, genre, available? | Weight, page colour, font |
| Member | ID, name, membership type | Height, shoe size |
| Loan | Book ID, member ID, date borrowed, due date | Weather on the day borrowed |
Step 3 — Define relationships: A member borrows books. A loan connects a member to a book.
This abstraction gives you a clear, manageable model to work from.
| Question type | What to do |
|---|---|
| "Explain what is meant by abstraction" | Define it as removing unnecessary detail; give an example |
| "Give an example of representational abstraction" | Describe a real-world situation and explain what details are kept and removed |
| "Explain how abstraction by generalisation applies to..." | Show how common features are identified across multiple instances |
| "Explain the importance of information hiding" | Discuss encapsulation, interfaces, reduced complexity, easier maintenance |
| "Describe the levels of abstraction in..." | List the layers and explain what each hides |
Exam Tip: When explaining abstraction, always give a concrete example. Saying "abstraction removes unnecessary detail" is not enough — you need to say what details are removed and why they are unnecessary in that context.