In this article, we are going to explore the notion of Abstract data type.
Abstract data type: what does it mean?
Abstract data structures are designed for easy storage and access to information. They provide a convenient interface for common stored object operations while hiding implementation details from the user. Of course, this is very convenient and allows you to achieve greater program modularity. Abstract data structures are sometimes divided into two parts: an interface, a set of operations on objects called an ADT (abstract data type), and an implementation.
The main idea of an ADT is that defining it, not only the structure of values of a type is specified, but also a set of permissible operations on variables and values of this type. In the most powerful case, access to the internal structure of a type is only available through its operations. Operations must include one or more type value constructors.
In programming, abstract data types are usually represented as interfaces that hide the corresponding type implementations. Programmers work with abstract data types exclusively through their interfaces, as the implementation may change in the future. This approach corresponds to the principle of encapsulation in object-oriented programming. The strength of this technique is the concealment of implementation. Once only the interface is published externally, as long as the data structure supports this interface, all programs that work with a given structure of the abstract data type will continue to work. Developers of data structures try, without changing the external interface and semantics of functions, to gradually finish implementations, improving algorithms on speed, reliability, and the used memory.
Advantages of abstract data types
The use of ADT has the following advantages:
- Encapsulation
Abstraction undertakes that any implementation of ATD has certain properties and abilities; knowing them is all it takes to use an ATC object. The user does not need any technical knowledge of how to work on the ATD to use them.
- Localization of changes
The code that uses the ATD object will not need to be edited if the ATD implementation has changed. Because any changes to the implementation must still match the interface, and since the code using the ATC object can only relate to the properties and capabilities specified in the interface, changes can be made to the implementation without requiring any changes in the code where the ATD is used.
- Flexibility
Different implementations of ATD have all the same properties and capabilities that are equivalent and can be used interchangeably in code that uses ATD. This gives great flexibility when using ATC objects in different situations. For example, different implementations of ATD may be more effective in different situations; you can use each of them in a situation where it is better, thus increasing the overall efficiency.
- High information content of the interface.
ADT allows you to represent the entire interface in terms of domain entities, which, you see, increases the readability and information content of the interface.