Abstract data types

Mathematical specification of a set of data and the set of operations that can be performed on the data. They are abstract in the sense that the focus is on the definitions of the constructor that returns an abstract handle that represents the data, and various operations with their arguments. The actual implementation is not defined, and does not affect the use of the ADT.

When realized in a computer program, the ADT is represented by an interface, which shields a corresponding implementation. Users of an ADT are concerned with the interface, but not the implementation, as the implementation can change in the future.

Construct abstract data types

The term abstract data type is about as dry and technical sounding as you can get. Yet the concept of an abstract data type, is something we should apply in every single one of our application efforts, sometimes without even realizing that we are doing it. An abstract data type is a collection of information and operations that act on that information. An ADT can represent computer objects such as lists, records, stacks, arrays, and tables; but an ADT can also represent real world objects, such as a company, a product or the set of assembly line operation at a factory.

PL/SQL offers several different constructs with which to build and manage ADTs, most importantly the package. The most general description of an ADT, in fact, sounds just like the description of a package: a collection of data and operations on that data.

Build an ADT in phases

There are four phases to build ADT, they are

  • Clarify the data to be represented by the ADT. Make sure you understand all the attributes of the data and the way it is used in your application.
  • List the key features and functions of the ADT as it relates to the underlying data. Don’t write any code until you have come up with a comprehensive list of all the operations on and by the ADT.
  • Build the interface for the ADT. This is equivalent to designing the specification of all the modules, which are called by programmers to manipulate the ADT. Translate the list of features into procedure and function calls.
  • Build the body of code behind the interface. You know how programmers will manage the ADT, since they must work with the specification. The final phase is to actually implement the ADT.