Sie sind auf Seite 1von 4

1999 by CRC Press LLC

chapter six
Object-oriented concepts
William S. Davis
6.1 Purpose
6.2 Strengths, weaknesses, and limitations
6.3 Inputs and related ideas
6.4 Concepts
6.4.1 Objects and object types
6.4.2 Encapsulation
6.4.3 Signals
6.4.4 Inheritance
6.4.5 Polymorphism
6.5 Key terms
6.6 Software
6.7 References
6.1 Purpose
The objective of the object-oriented approach to software development is to
support creating software that is easier to change, debug, and maintain than
is traditional software. Today, object-oriented principles are also applied to
system development.
6.2 Strengths, weaknesses, and limitations
The object-oriented approach offers many advantages over traditional soft-
ware (and system) development. Object-oriented software and systems are
intuitive. Objects are things that really exist, events are things that really
happen, and real-world objects really do respond to something like signals.
7001_PDF_C06.qxd 10/23/2001 13:58PM Page 43
1999 by CRC Press LLC
Object-oriented software and systems are easier to change, debug, and
maintain than are traditional structured software and systems because they
are highly modular. Because the modules reflect natural classifications, they
tend to be more independent and more stable than the somewhat arbitrary
modules suggested by traditional structured techniques. Because data and
methods are grouped in the same object, ripple effects are isolated and thus
easier to trace.
The object-oriented approach to software development supports
reusable code. The principle of reusability is imbedded in the theory that
underlies object-oriented software.
Object-oriented software is often less efficient than structured software
on traditional single-processor computers. Note, however, that object-
oriented software may actually be more efficient on the parallel systems that
are evolving.
More significantly, relatively few programmers are trained in the object-
oriented approach, leading to personnel shortages, and adding to software
development expense. Current academic curricula are beginning to stress
object-oriented software, however, so this problem may grow less severe
given time.
6.3 Inputs and related ideas
Object-oriented analysis is discussed in Chapter 29. Object-oriented soft-
ware design is discussed in Chapter 66.
6.4 Concepts
An object is a thing about which data are stored and manipulated. It might
be a physical thing such as a person, a customer, a book, or an item in inven-
tory. It might be an abstract thing such as a model, a concept, or a process.
Unlike many technical terms, the word object means what people intuitively
think it means.
6.4.1 Objects and object types
To avoid being swamped by the sheer number of objects, similar objects are
grouped to form classes or object types. Classifying or grouping objects
makes it easier to track them.
An individual object is a single instance (or occurrence) of an object class
(or object type). For example, a given computer (the object itself) has a
unique serial number. That particular computer is but one instance of a
given model. Moving up the classification hierarchy, a store might distin-
guish between tower, desktop, laptop, and hand-held computers. Finally,
computers, printers, boards, software, supplies, books, and services clearly
represent different categories.
7001_PDF_C06.qxd 10/23/2001 13:58PM Page 44
1999 by CRC Press LLC
6.4.2 Encapsulation
Both data (attributes) and methods (processes) are associated with an object.
For example, an item in inventory might be described by listing such attri-
butes as its product code, a brief description, its selling price, and so on. A
method is a process that accesses an object. For example, associated with a
given product in inventory are methods for placing it in inventory, changing
one of more of its attributes, removing it from inventory, and so on. Methods
define how the objects data are manipulated.
In an object-oriented program, an objects data and methods are bun-
dled so that the only way to access the data is through the objects own
methods. Hiding implementation details in this way is called encapsulation.
The only way other objects can obtain a given objects data is through one of
that objects own methods.
6.4.3 Signals
Because the objects in a well-designed object-oriented system are encapsu-
lated, they are isolated from each other and changes to one object cannot
inadvertently affect others. Objects do not exist in a vacuum, however. They
interact with other objects by transmitting and responding to signals.
Signals are generated by events. An event occurs when an objects state
changes. Achange in state usually implies a change in the value of one of the
objects attributes. The only way to change an attribute is through one of the
objects own methods, so events imply methods.
An operation is an external view of an object that can be accessed by
other objects. An operation is implemented by one of more methods. In
effect, an operation is a method (or methods) that responds to or generates
external signals.
Note that a given event does not direct its signal to a specific target
object. Instead, the initiating event simply broadcasts the signal. Other
objects might respond to the signal or ignore it, but the source object neither
knows nor cares. In this case, indifference implies independence.
6.4.4 Inheritance
A Mazda Miata can be described as a small, sporty, two-seat automobile.
Because it is a type (subclass) of automobile, all the attributes the Miata
shares with other automobiles (four wheels, an engine, a cooling system,
methods for propulsion, steering, and stopping) can be assumed.
Moving down another level, a specific Mazda Miata (an object) can be
described in terms of the attributes that make it unique (red, convertible
top, serial number), and the attributes it shares with other Miatas (small,
two seats, sporty) can be assumed. In effect, each subclass borrows (or
inherits) attributes and methods from its superclass. This concept is called
7001_PDF_C06.qxd 10/23/2001 13:59PM Page 45
1999 by CRC Press LLC
6.4.5 Polymorphism
Agiven operation or method is considered polymorphic if it produces sim-
ilar results in different objects or at different levels. For example, a customer
sale, a customer return, the arrival of a shipment, and the completion of a
physical inventory are all events that can change the value of the inventory
stock-on-hand for a given object type. The general structure of the invento-
ry update method might be inherited from the highest-level class, and then
customized for each of these special cases.
6.5 Key terms
Class (object type) Agroup of similar objects.
Encapsulation Hiding implementation details by bundling an
objects data and its methods so that the only way to access the data
is through the objects own methods.
Event An occurrence that generates a signal.
Inheritance The principle that allows an object to get attributes and
methods from its superclass.
Method Aprocess that accesses an object.
Object Athing about which data are stored and manipulated.
Object type (class) Agroup of similar objects.
Operation An external view of an object that can be accessed by
other objects.
Polymorphism The property of an operation or method that allows
it to produce similar results in different objects or at different levels.
Signal Amessage that allows objects to interact with other objects.
State Aset of attribute values for an object.
6.6 Software
Not applicable.
6.7 References
1. Budd, T., An Introduction to Object-Oriented Programming, Addison-Wesley,
Reading, MA, 1991.
2. Davis, W. S., Business Systems Analysis and Design, Wadsworth, Belmont, CA,
3. Martin, J. and Odell, J. J., Object-Oriented Analysis and Design, Prentice-Hall,
Englewood Cliffs, NJ, 1992.
4. Winblad, A. L., et al., Object Oriented Software, Addison-Wesley, Reading, MA,
7001_PDF_C06.qxd 10/23/2001 13:59PM Page 46