Next: 2.2 Design of the
Up: 2. The Algorithm Library
Previous: 2. The Algorithm Library
2.1 Object-Oriented Programming
Object-oriented programming has been a very heavily (and often misused)
catchword in recent days coming up with quite a number of different and
partially contradicting interpretations of the involved concepts. This
fuzziness is the result of the complex roots of the object-oriented
programming concepts in conjunction with the huge variety of competing
programming languages putting it into practice [2,10].
The first programming language utilizing objects is
Simula [11] which was aimed at supporting simulation
activities. Procedures could be attached to a type (a class in Simula's
terminology) to represent the behavior of an instance. Amongst many others
the most popular object-oriented programming languages Smalltalk,
Eiffel, Objective-C, and C++ evolved, each introducing own specific
nomenclatures and interpretations of the key features of
object-orientation.
Therefore the basic ideas and most important notions shall be summarized in
this chapter clarifying their exact interpretation in the remaining parts
of this text. Note that these interpretations are closely related and
compatible to the corresponding definitions used by B. Stroustrup for C++
[58,59,1].
The central concept in this context is the object. Summarizing
different implicit and explicit definitions in [10,7,48]
a object represents an identifiable entity able to span a state space and a
number of operations (behavior) to either examine or affect its state or
the state of peer objects. Based on this definition object-oriented
programming comprehends the following programming paradigms and notions:
- data encapsulation: Semantically interdependent data items
(members) are grouped into an aggregate (class) to form a
single data item. The grouping instructions are summarized in the
class definition. Implementations of these class
definitions which allocate certain system resources per item are
commonly addressed as (class) instances or objects.
- function encapsulation: Algorithms are coded as a sequence of
statements grouped together forming functions. While the concept of data
and function encapsulation is available in most of the procedural
third-generation languages, object-oriented programming languages provide
the concept of
- data and function association: Definite relations between data
items and functions processing them are generated. In this context the
functions associated with the class definition are called (class)
methods. Consequently special functions can be used to define
operators working on data items of specific user defined
classes. Thus user defined data types can be defined which behave
almost like the built-in data types of the language itself. This concept
is often referred to as data abstraction.
- inheritance: Structural relationships between classes in the form
``class A'' is a kind of (implementation of) ``class B'' can be expressed
by means of data and function inheritance. In these terms
inheritance means, that the derived class A inherits data members
and methods from the parent class B with a single declaration of
their relationship. Inherited members and methods are
indistinguishable from intrinsic members and methods defined on the
class.
- overloading: To implement different flavors of certain concepts,
object-oriented languages provide the method of overloading method and
data members inherited from a base class in the derived class. Thereby
it is possible to define an interface class providing method
definitions which are common to a certain group of classes. Classes
which are derived from this interface class can either implement own
versions of these methods or rely on the implementation in the parent
class. All classes which are defined by inheriting from the
interface class or from other classes which are derived from the
interface class in this manner are called implementations
of the interface class. The derived classes also are denominated
as classes of the type of the interface class.
- runtime type identification: Each instance of the
different class types can be identified at runtime. This
identification works also for references to the object whether the
reference points to a class with the actual object type or to one
of its parent classes. This feature allows for containers of references
to base classes without loosing the information about the actual type of
the stored objects, which is a big advantage over statically typed
languages like C or PASCAL.
- polymorphism: The availability of runtime type information for
object references enables the concept of consistently using references to
a common interface class of a group of classes instead of
references to the actual class. Such a reference represents all different
implementations of the interface and is therefore entitled as
polymorphic reference. Two types of methods can be defined for
such classes. When normal methods of the interface class are invoked the
method definition of the interface class is evaluated. When virtual
methods of the interface class are invoked the method definition of
the actual class definition represented by the reference to its interface
class are computed.
Next: 2.2 Design of the
Up: 2. The Algorithm Library
Previous: 2. The Algorithm Library
Robert Mlekus
1999-11-14