Objectives
This section discusses how abstract data types
may be realized.
Traditionally, abstract data types are realized
as a collection of functions grouped in a module,
hiding the implementation details from the user.
Objects allow for a different kind of decomposition
and instead provide a method interface by
which each instance of the type may be uniformly
addressed.
We show, following [Cook90], that these two approaches
are complementary and discuss the trade-offs involved.
Points to emphasize
- data abstraction -- generators/observers matrix
- modules -- operation oriented
- objects -- data oriented
Hints
The first programming languages for many students
is, still, Modula-2.
Students are, therefore, probably familiar
with the realization of abstract data types as modules.
Hence, nothing less then a change of attitude
is involved to appreciate the realization
of abstract data types by means of objects.
Questions
- Explain how you may characterize an abstract data type
by means of a matrix with generator columns and observer
rows.
What benefits does such an organization have?
- How would you characterize the differences between
the realization of abstract data types by modules
and by objects?
Discuss the trade-offs involved.
Comments
The ADT implementation corresponds to an implementation
in C style, whereas the decomposition into
generator subclasses only presents one of the
approaches possible for C++.
In practice, a hybrid version would probably be more
likely.