MENTAL
 Main Menu
 Applications
 Computer Science
 Data Abstraction


Data Abstraction
 DATA ABSTRACTION

"The revolution in data abstraction has affected the entire spectrum of language design, programming methodology, and the way we think about programs" (Judy Bishop).



Abstract Data Types

Primitive and derived data types

First, we must distinguish between primitive and derived data types:
Abstract data types

An abstract data type (ADT) consists of two layers or levels:
  1. The inner level. This is the implementer level, which is hidden from the user. At this level is the data structure. The feature of hiding the implementer details of a data object is called "encapsulation".

  2. The outer level. This is the conceptual and usage level, which is the public interface. The interface is constituted by a set of operations defined on the data structure of the inner level.
The public or external interface corresponds to the "what", to the specification. The private or internal part corresponds to the "how", to the implementation.

The ADT has the implementation hidden from the user. But if it is exposed, we speak of a "transparent" data type.

Typical operations on a data structure are: store, retrieve (or access), select, modify, delete, etc. elements (or objects) in the data structure. The set of operations that can be performed with a ADT is closed, i.e., it can only be accessed through the interface, which is fixed. By their very nature, ADTs are dynamic data structures.

A ADT can be defined as a class of objects (or elements) defined by a structure, a set of values, a set of operations, and a set of constraints defined as preconditions and postconditions.

In OOP (Object Oriented Programming), a ADT is a class of objects because the public interface is parameterized. An instance of a class is an object.

All high-level languages have predefined ADTs, but the user can define his own ADTs.


Examples

Data structures that can be implemented as ADTs are: sets, sequences, stacks, queues, vectors, graphs, containers, dictionaries, maps, algebraic structures (groups, rings, lattices, etc.), etc. For example:
Advantages of ADTs

There are two main advantages:
  1. It simplifies programming, since it allows the programmer to operate with the data from a higher level of abstraction, in a conceptual way, without having to know the details of its implementation.

  2. The implementation may change over time (for example, to improve performance or consume fewer resources), but not the interface, so the source code remains unchanged.

MENTAL and Data Abstraction

The history of programming languages is linked to increasing abstraction. A process of abstraction consists of focusing on the essential characteristics of something, disregarding the particular, accessory or contingent. The fundamental problem in the design of software systems is to reduce complexity, and this objective necessarily involves the process of abstraction. The first abstraction that appeared was the procedural abstraction. Subsequently, other abstractions appeared: objects, functions, rules, events, aspects, agents, etc., including ADTs.
The variable as the simplest ADT

A variable x can be considered a dynamic ADT that has two operations:
  1. Store a value v in the variable x: (x = v).

  2. Access the value of the variable. This is done by simply mentioning x:
The next level in ADT complexity is a parameterized variable:
where x, y, z can be any expressions. For example:

Container example

A container consists of a set of elements. Each element has a key and associated data. The key and data can be as complex as desired. For example, a key could be a parameterized variable. We are as in the previous case. Examples: In this example, YearBirth and PlaceBirth can be considered as containers.


Example of stack

If we call s the stack name and x the value to add, we have the following operations: The stack has been implemented as a one-dimensional array, but it could have been implemented as a sequence or in any other way, but from the user's point of view, the interface is unchanged.



Addenda

History of ADTs
Bibliography