Data abstraction is realized by user-defined abstract data types (ADTs)
ADTs promote encapsulation, modularity, information hiding, and genericity
ADTs paved the way to object-oriented methodology; full OOP includes the concepts of objects, inheritance, template classes and polymorphism
An abstract data type is a user-defined data type that satisfies two conditions:
Modularity: The representation of and operations on objects of the type are defined in a single syntactic unit; also, other units can create objects of the type. Modularity supports reusability and good program organization.
Encapsulation: The representation of objects of the type is hidden from the program units that use these objects, so the only operations possible are those provided in the type's definition. Encapsulation supports security and reliability. (this is the use of private in C++)
Parameterization: The ability to define a generic data type is optional. Generic data types promote code reusability (Ada and C++ but not Java include this)
C++ Standard Template Library (STL) -
The STL, a later edition to the C++ standard, is a set of abstract datatypes, functions, and algorithms designed to handle user-specified datatypes. Each of the abstract datatypes also contains useful functions, including overloaded operators, to access them. The underlying methoology of the STL is generic programming - the implementation of algorithms or data structures without being dependent on the type of data being handled. For instance, the STL vector container can store a vector (a resizable array) of any object you desire. In C and non-STL C++, you can use arrays to get a similar feature, but arrays are limited to a single type of data structure. Moreover, the STL provides some nice features such as handling memory for you (no memory leaks), and it is also safer (no buffer overflow issues when using vectors or similar data structures).
Simula provided encapsulation but not information hiding. Ada, C++ and Java provide all three. ObjectAda now has full OOP support with classes.
Ada introduced and embodies many of the modern principles of software engineering
Ada's design for exception handling was state-of-the-art in 1980 and the only widely used language with exception handling until C++
One aspect of reliability is to catch as many errors as possible before runtime; Ada is strongly typed: there is no assignment coercion
The encapsulation construct is the package:
package is type NODE_TYPE is private; private type NODE_TYPE is record end record;
package INT_STACK is new GENERIC_STACK(100, INTEGER); package FLOAT_STACK is new GENERIC_STACK(500, FLOAT);
Some means of partial compilation (compilation units that are smaller than the whole program)
Obvious solution: a grouping of subprograms that are logically related into a unit that can be separately compiled (compilation units)
Compilation units are encapsulations - access across a compilation unit must be intentional
languages with strong encapsulation (Ada and Java) make a compilation unit one class or procedure