What is object-oriented programming?
1982
What is object-oriented programming?
My guess is that object-oriented programming
will be in the 1980s/1990s
what structured programming
was in the 1970s.
Everybody will be in favor of it.
Every manufacturer will promote his products as
supporting it.
Every manager will pay lip service to it.
Every programmer will practice it.
And no one will know just what it is.
\zline{untraced quotation}
slide: Object Oriented Programming
Perhaps unfortunately, it is not true that currently every programmer
uses an object-oriented language.
Nor is it true that everybody is in favor of object orientation.
To study object-oriented programming, however, the least one
can do is to become familiar with the terminology employed.
In this section, we will discuss the terminology associated
with object orientation, and look
at what features and benefits are generally acclaimed
by proponents of an object-oriented approach.
Object terminology
Objects provide the means by which to structure a system.
In Smalltalk (and most other object-oriented languages) objects are considered to
be grouped in classes. A class specifies the behavior of the objects that
are its instances. Also, classes act as templates from which actual objects may be created.
Inheritance is defined for classes only.
From the perspective of design, inheritance is primarily meant
to promote the reuse of specifications.
See slide [1-speak].
Object terminology
\zline{\fbox{object speak}}
- objects -- packet containing data and procedures
- methods -- deliver service
- message -- request to execute a method
- class -- template for creating objects
- instance -- an object that belongs to a class
- encapsulation -- information hiding supported by objects
- inheritance -- mechanism allowing the reuse of class specifications
- class hierarchy -- tree structure representing inheritance relations
- polymorphism -- to hide different implementations behind a common interface
slide: Object terminology
The use of inheritance results in a class hierarchy
that, from an operational point of view,
determines the dispatching behavior of objects,
that is what method will be selected in response to a message.
If certain restrictions are met (see sections [contracts],
[subtypes] and [types-behavioral]),
the class hierarchy corresponds to a type hierarchy,
specifying the subtype relation between classes of objects.
Finally, an important feature of object-oriented
languages is their support for polymorphism.
Polymorphism is often incorrectly identified with inheritance.
Polymorphism by inheritance makes it possible
to hide different implementations behind a common interface.
However, other forms of polymorphism may arise by overloading functions
and the use of generic (template) classes or functions.
See sections [1-poly] and [flavors].