Instructor's Guide
introduction
themes
paradigms
lifecycle
trends
summary
Q/A
literature
When programs became larger and data more complex, the design of correct algorithms
was no longer the primary concern.
Rather, it became important to provide access to data in a representation
independent manner.
One of the early proponents of data hiding was, see [Parnas72a]
and [Parnas72b],
who introduced a precursor to the notion of data abstraction
as it has become popular in object-oriented languages such as Smalltalk or C++.
As a language that supports data hiding, we may think of Modula-2 that offers
strong support for modules and the specification of import and export relations
between modules.
Also the package construct of Ada provides support for data hiding.
See slide [1-abstraction].
Modules as provided by Modula-2 and Ada give a syntactic means for decomposing a program
into more or less independent components.
It is precisely the purely syntactic nature of modules that may be considered
the principal defect of this approach to data hiding.
Semantically, modules provide no guideline with respect to how
to decompose a program into meaningful components.
Support for data abstraction
- Abstract Data Types -- encapsulation
Encapsulation
- initialization
- protection
- coercions
slide: Data abstraction
To express the meaning of a module, we need the stronger notion of types,
in the sense of abstract data types which are characterized
by a set of operations.
The notion of types as for example supported in CLU,
[Liskov74],
enables us to determine whether our decomposition satisfies
certain formal criteria.
For instance, we may ask whether we have defined sufficiently
many
operations for a given type and whether we have correctly done so.
An important advantage of using abstract data types is that we can often
find a mathematical model that formally characterizes the behavior of that type.
From the perspective of formal methods,
data abstraction by means of abstract data types may be considered as one of the
principal means for the specification and verification of complex software
systems. See also sections [adt-modules] and [formal-coop].
From an implementation perspective,
to support data abstraction a language must
provide constructs to implement concrete realizations
of abstract data types.
Such support requires that means are provided to
create and initialize elements of a concrete type
in a safe way,
and that vulnerable data is effectively protected.
Very important is
the possibility of defining generic types,
that is types which take a (type) parameter
with which they are instantiated.
For example, the definition of a stack does not
differ for a stack of integers, a stack of strings
or a stack of elements from an arbitrary user-defined type.