Abstract Data Type
CSL 102; Data Structures; IIIT Nagpur; Created by: Dr. Aniket Pingley
Motivation
Let us take two everyday examples as follows:
- Driving a car: A car is complex system of machines. It has a combustion engine, a gear box, a transmission system, a fuel tank etc. that work together to make a car move from one point to another point. A driver inside the car, however has a few things that they directly handle, i.e. a steering wheel, the gear lever, accelerator, brake and clutch. To drive a car, one must know how use the aforesaid in the correct combination. However, the knowledge of how combustion engine burns fuel to generate energy is not required for driving a car. The driver also does not need to worry about the ratio of RPM to torque or the amount of brake horse power being output in order to drive a car (not true for a Formula One driver of course).
- Using a remote control for TV: In order to change channels, manipulate volume or set audio/visual profile of a TV, one has to know how to use a TV remote. One does not need to understand the LED/LCD technology, embedded software or any electrical components house in a TV.
In both the examples above, the internal functioning of the system is abstracted for the user. Instead, an interface to the complex systems, i.e. steering wheel, gearbox, remote control etc. is made available to the user. The expected output for an action or a series of action is well-defined/documented.
Designing a good interface that is lucid and intuitive having well-defined mapping of actions to outcome is a good characteristic of any software. It is often that a sophisticated software application is created by developing several modules independentely first and then plugged together. Thus, it is important that every module and the pieces of functionality inside it also demonstrate the aforesaid characteristic.
The meaning of Abstraction
Loosely speaking, abstraction is a sum-total of a four principles of software development. They are as follows:
- Abstraction: Omitting the details of implementation and focussing on the way to access and use a functionaltity as defined/documented by the interface (e.g., a set of functions in the math library, i.e. math.h in C language)
- Modularity: Designing a system as an assemblage of modules, each of which can be implemented and tested seperately from rest of the system.
- Encapsulation: Making a module behavior independent of the functioning of rest of the system. And, implementing a module in a manner such that any changes to its implementation must not require any change to rest of the system.
- Seperation of concerns: Designing a system such that no module is responsible for more than one feature. For example, logging debug/warning/error messages to file or system logs should be managed by one module.
In the following image below it can be clearly seen that an ADT has an interface exposed to the client/user. However, the internals of the ADT, such as base data structures, e.g. array are hidden/internal/encapsulated.
Image source: https://sarick.me/
Operations on ADT
Following operations are listed that can be performed on an ADT from the perspective of C programming language.
- Creation: A new instance of the data type is created in memory via functions made available via the interface.
- Modification: Data of the ADT can be updated via functions made available via the interface.
- Observation: Data of the ADT can be obtained via the interface.
HOME PREV NEXT