Data Abstraction
Why abstraction?
When you drive a car, you use the steering wheel, the accelerator, and the brake.
You do not need to know how the engine works internally. The internal mechanism can change (petrol engine, diesel engine, electric motor) while the controls you use stay the same.
That is abstraction. Hide the complexity inside. Expose only what the user needs.
The same idea applies in programming. Suppose you use a stack (a data structure covered in detail in a later lesson, no need to worry about it yet). As a user, you care about push, pop, and peek. You do not need to know whether the stack is implemented using an array or a linked list. The implementation can change while the operations exposed to the user remain the same.
That idea is data abstraction.
Definition
Data abstraction is the process of hiding unnecessary implementation details and exposing only the essential features and operations.
How it looks
ABSTRACTION
The user sees the behaviour, not the internal mechanism.
Quick recall
- Data abstraction hides implementation details and exposes only essential operations.
- The internal representation can change without affecting code that uses it.
- This idea underlies the concept of an Abstract Data Type (ADT), covered next.