Database Reference
In-Depth Information
Repeated
Single
EMPLOYEE
PERSON
EMPLOYEE
MANAGER
ENGINEER
ENGINEERING
MANAGER
MANAGER
ENGINEER
Selective
Multiple
PERSON
MANAGER
ENGINEER
EMPLOYEE
ENGINEERING
MANAGER
Figure 20-6
Types of inheritance.
Inheritance
Consider two classes, EMPLOYEE and MANAGER. The two classes share a
number of attributes and, perhaps, a reasonable number of methods. In addition to
the attributes of the class EMPLOYEE, the class MANAGER may have a few more
specialized attributes. Nevertheless, the two classes are substantially similar.
A feature of object orientation, known as inheritance, allows a class to be defined
as a special case of a more general class. Such special classes are called subclasses,
and the general classes are called superclasses. When you form a superclass from a
specialized class, the process is known as generalization. Similarly, the process of
forming a subclass from a general class is called specialization. The concepts of
generalization and specialization discussed here are similar to what we discussed in
Chapter 6 for the object-based data model.
Inheritance may be of different forms: single, multiple, repeated, and selective.
Figure 20-6 presents the various types of inheritance.
Polymorphism
This is a powerful concept in object orientation. To understand the concept, first
consider the general concept of overloading. Consider any specific method defined
within a class. The method has a name. Overloading allows the name of any specific
method to be reused within the class or across different classes. Do you realize what
this powerful technique can accomplish? Just a single message can perform differ-
ent functions depending on the receiver object and the parameters passed to it. The
context of the method determines its function.
Polymorphism (having many forms) is more general than overloading. Three
types of polymorphism exist.
Search WWH ::




Custom Search