The abstract data type (ADT) is a data type that focuses on what it does by ignoring how it does. The Best example of this Abstract data type is stack and queue.
Stack having its push and pop operations, but it is implemented using the array or linked list. There is also a complex logic behind the push and pop operations of the stack, but we never focus on that.
Lets spread Abstract data type in two parts “Abstract” and “data type” to understand it well.
Data Type: Data type describes the variables, is the set of values that the variable can take. We have already seen previously. Some basic data types in C are int, char, float, and double.
When we talk about a primitive type data type, basically we consider two things: one is a data an item with certain characteristics and another one is permissible operations on that data.
For example, an int variable can contain the value from –32768 to 32767 and can be operated with the operators +, –, *, and /.
Therefore, If we declare a variable of an abstract data type (e.g., stack or a queue), then the above operations that should also be performed on it.
Abstract: The word ‘abstract’ means hide the complex internal implementation, only show the functionality.
In C, an abstract data type can be a structure considered only its functionality without regard to its implementation. This structure has any numbers of methods that are defined to perform various tasks. This method is already defined, but the end-user is not concerned about the internal implementation of these methods, and also end-users are not aware of how that methods carry out their tasks.
They are only aware of the methods name and their operations that are available and documented. They are only concerned about how to call these methods and to get the results after the computation by these methods. They are not concerned about how they work.
For example, In a stack or a queue data structures, there are some specified predefined operations. Like On stack data structure, we can apply push and pop operations. The users have concerned only with that the type of data and the operations that can be performed on it. But the users are not aware of how the data is stored in the memory. They should not be concerned with how the methods work or what structures are being used to store the data.
For the stack, data structure user should just know that the stack has push() and pop() functions. Using these functions push() and pop(), user can manipulate the data (insertion or deletion) stored in the stack.
- ADT is robust and reusable.
- It is based on the principles of Object-Oriented Programming (OOP) and Software Engineering (SE).
- An ADT can be re-used at several places, and it reduces the coding efforts
- ADT ensures a robust data structure
- Allows better conceptualisation and modelling of the real world
ADT approach is based on the SE concepts of coupling and cohesion Coupling property determines
- How strongly two separate parts of programs are linked together
- Extend to which changes made in one part impacts the other parts of a software module
Well, designed software has a minimum coupling. An ADT promotes weak coupling. Cohesion determines how well-integrated are components of the software. An ADT inherently promotes maximum cohesion.