Understanding: Paradigm
Understanding: Paradigm
UNIFYING PARADIGM
the object-oriented design paradigm with the other four concepts in construct for implementing a user-
and will discuss how these properties specific ways that characterizes defined type. For example, in Figure
reinforce the concepts of good design. object-oriented programming. The 2 the variables main-menu and
The paradigm sprang from lan- paradigm is new enough, however, sub-menu are both type MENU.
guage, has matured into design, and that there is not universal agreement Execution of the statement
has recently moved into analysis. on how to characterize it. Other Main-menu.create dynamically
The blurring of boundaries between definitions can be found in [5, 281. allocates space for the object
these phases has led us to include In the following discussion we “Main-menu.” Subsequent
topics in this article that are outside introduce and illustrate each of the execution of the statement
the realm of design, but which we five concepts using Eiffel syntax and sub-menu. create dynamically cre-
consider important to understanding semantics. ates a second instance of the MENU
the design process. Since the para- Figure 1 shows a’ group of related class.
digm sprang from language, we classes referred to as a subsystem or Ideally, a class is an implementa-
define the concepts basic to object- a class cluster [14]. This cluster im- tion of an ADT. This means that the
oriented programming in the follow- plements all of the types necessary for implementation details of the class
ing section. implementing a simple hierarchical are private to the class. The public in-
menu system. terface of such a class is composed of
Basic Concepts 06 two kinds of class methods. The first
OBJects kind consists of accessor functions
Object-Oriented
ProgrammIng Objects are the basic run-time that return meaningful abstractions
lnherltance
FIGURE a. Groulpof Related ClassesReferredto as a Subsystemor ClassCluster. Inheritance is a relation between
- X (base
ciass)
incremental part. The derived part
is the part inherited from X. The
incremental part is the new code,
written specifically for Y.
The mapping from the members
of X to the derived members of Y is
kinds of mappings require additional
information. For example, if a given
member of X is to be reimplemented
as it is mapped to Y, the code for
reimplementation must be given.
The inheritance relation is often
defined by the rules of the language called the “is a” relation. This is
in conjunction with code written because when a class Y inherits from
by the programmer in class Y. The class X, class Y now has, by in-
0
mapping may be a simple identity in heritance, all the features of X. Thus
which the derived part of Y is Y is an X. Y is undoubtedly more
exactly the same as the members of than an X, but in addition to what-
X. This inheritance mapping may ever else it may be it is also an X.
however, be much richer than a Because of this, the inheritance
simple identity. relation is often used to reflect
In general, a feature of X may be abstraction and structure present
renamed, reimplemented, dupli- in an application domain. A com-
cated, voided, have its visibility monly used example domain is from
changed, or undergo almost any graphics. A rectangle is a special kind
other kind of transformation as it is of polygon (see Figure 4). This rela-
for rectangles “as is” but the calcu- is tightly coupled with the idea of this concept. In a graphics system we
late-area procedure should be polymorphism in a strongly typed may want the ability to perform some
redefined to give a more efficient object-oriented language. The idea is action (such as scale or rotate) on all
implementation. that if Y inherits from X, Y is an X, currently displayed figures. It would
In an object-oriented graphics and therefore anywhere that an in- facilitate this operation if a list of all
system, inheritance minimizes the stance of X is expected, an instance displayed figures were available.
incremental effort of adding a new of Y is allowed. Referring to the inheritance
graphics primitive. In the same man- Figure 5 provides an outline for diagram of Figure 4, one can see that
ner, the object-oriented approach discussion. After execution of state- the variable “current-figures:
with inheritance facilitates rapid ment 1, the static type of x is X and ARRAY [Figure]” provides just
prototyping. the dynamic type of x is X. After what is needed. Since Figure is an
The real appeal and power of the statement 4, the static type ofx is still ancestor of Circle, the Eiffel type
inheritance mechanism is that it X but its dynamic type is now Y. system knows that Circle is a Figure
allows the programmer to reuse a A more realistic example will help and allows the assignment: cur-
class that is almost, but not exactly, to clarify the use and importance of rent-figures.put(Cl:,l); {where Cl
what he wants, and to tailor the class
in a way that does not introduce
unwanted side effects into the rest of
the class. Furthermore, the object
paradigm focuses on identifying and
is an object of type Circle}. After this binding. To redraw the entire analysis process serves as input into
assignment the static type of graphics window the following code the design phase but it is in a different
current-.&ures.item(l) would still would suffice: terminology and represents a dif-
be figure, but its dynamic type would Fori: = 1 to Number-of- ferent perspective from the design
be “circle.” Likewise, the elements Shapes phase. For this reason, the traditional
2...n of the array could be Squares, do view of an application life cycle in-
Lines, or any other graphics current&ures.item(i).draw; cludes what may be an unnecessary
primitive. At each pass through the loop, the boundary between analysis and
code matching the dynamic type of design. This boundary results from
currentfigure.item(i) will be called. a shift from the problem domain in
The binding referred to in this sec- Note that if additional kinds of analysis to the solution domain in
tion is the binding of a procedure call shapes are added to the system, this design.
to the code to be executed in response code segment remains unchanged. The object-oriented design
to the call. Dynamic binding means Contrast the resulting simplicity and paradigm takes a modeling point of
the code associat.ed with a given pro- extensibility as compared with a view. The analysis and design phases
cedure call is not known until the traditional case statement design. of the traditional life cycle, while re-
moment of the call at runtime. maining distinctly separate activities
In the object-oriented world, Bask Design Coneepes in the object-oriented life cycle, work
dynamic binding is associated This section presents the fundamen- together closely to develop a model of
with polymorphisrn and inheritance tals of the object-oriented design the problem domain. The model is
breviated statement of requirements pieces of the problem. information than other data models
for a software system which would To the former because the design such as the relational model.
control the traffic lights at the in- will retain and build directly upon Peckham and Maryanski [18] pro-
tersection of two streets. The applica- the objects identified during analysis, vide a survey of several semantic data
tion would have software interfaces and this facilitates communication models. Other techniques have been
to the hardware pieces like the car between users and designers since proposed for capturing this informa-
sensors and the traffic lights. users are better able to relate to the tion (e.g., Wirfs-Brock [28]).
The procedural paradigm ap- problem than to the computer-based A comparison of the information
proaches the development of the solution to that problem. in Figures 7 and 8 illustrates the dif-
traffic intersection control system by The entities identified above and ference in points of view of the two
considering the sequence of tasks that several others are illustrated in paradigms. Neither technique con-
must be performed. A functional Figure 8. This figure uses an entity- centrates on one type of abstraction
decomposition of the proposed solu- relationship diagram to present the to the exclusion of all others. The
tion provides a set of tasks such as entities and the relationships between procedural paradigm, while giving
those in Figure 7. This hierarchy them. The diagram is the represen- priority to procedural abstraction,
chart illustrates the process of step- tation of a semantic data model of must consider the structures nec-
wise refinement. Each layer in the the problem. A semantic data model essary for data representation at
hierarchy represents the identifica- is so named because it allows some level in the design process.
tion of more detailed functionality. representation of a broader range of Likewise, the object-oriented para-
The tasks are sequenced by reading
digm may use functional decomposi- of the commonality of the object together by the incident of a flight.
tion in designing the operators model. In one phase the analyst iden- The flight is also an entity which has
needed to manipulate an object. tifies problem domain objects while a state that describes the particular
The object model supports the in the next phase, the designer airplane and the particular pilot as
complete software d,evelopment life specifies additional objects necessary well as passengers, cargo, etc.
cycle. Beginning in the requirements for a specific computer-based solu-
phase, objects are identified. By tion. The design process is repeated Relatlonshlps
developing specifications of the en- for these implementation-level ob- The relationships between entities
tities found in the problem domain a jects. The position of object-oriented are the interactions that occur be-
clear and well-organi:zed statement of design in the software development tween objects in the problem space.
the problem is actually built into the process is further detailed in the A pilot flies an airplane. Flies is one
application. These objects form a paper by Henderson-Sellers [9] ap- relationship between pilot and plane.
high-level layer of definitions that are pearing in this special issue. This relationship is an application-
written in the terminology of the level relationship and is expressed in
problem domain. During the reline- Enf Ities the terminology of the problem. Two
ment of the definitions and the im- Object-oriented design is first con- entities may have more than one rela-
plementation of the application cerned with entities-things. These tionship between them. The pilot
entities, other entities, or classes, are things may be tangible objects such is-in-command-of the airplane.
identified. Figure 9 illustrates the as traffic lights, chairs, or airplanes. An entity may have relationships
layers of object specifications that The entities may be abstract concepts with several other entities. The pilot
0 is_part-of
CQUM”lllCITlClsCFT”EACDIlSeptcmber 199O/Vol.33, No 9
I I I I I I I I I I I
oped by connectiag instances of the several ways but they all involve configuration. Much of the process
classes-modeling the real world so messages. A message is a communi- is guided by the real-world problem
that they interact with each other cation between t.wo objects. The domain rather than our view of the
resulting in a problem solution. messaging may be either syn- problem solution. This results in an
The class descriptions include chronous or asynchronous depend- application design that, at a high
three parts: definitions of attributes, ing upon the execution model level, contains a model of the prob-
description of the c:lass interface, and chosen. An object may send a lem domain. The application design
the set of valid transitions between message to any other object whose process begins at a top level and
the possible states for an instance of identity is available. The message proceeds through class identification
the class. Consider the design of a can correspond to any operator in to a low level and then moves upward
stack class. Figure 10 shows the three the public interface of the receiv- as low-level classes are designed
parts of the class design. Part (a) of ing object. The receiving object may based on lower-level definitions.
the figure shows that the data at- be an object at the same design level
tributes for the stack class include a or it may be one that is declared as Support #or Dood Des&n
data store for the items contained in part of the implementation of the Modularity. The object-oriented
the stack and some means oflocating sending object. paradigm provides natural support
the top, or visible, item in the stack. Semantic data modeling provides for decomposing a system into
Part (b) gives the public interface of support for developing a complete modules. In this paradigm classes
the class. Part (c) uses a state diagram data model of an application which are the modules. This means that not
to illustrate the sequence of valid incorporates both high-level applica- only does the design process support
class person
public interface:
print-name();
tell-age();
private interface:
name: string;
date-of-birth: date;
is-a
-- public interface:
which-airline();
FAA-license-expirationo;
private interface:
airline: string;
FAAJzense: IicenseJype;
8 person
7 - FIGURE
end pilot;
related. This cluster of classes is a Weak Coupling. Classes are de- another class. This coupling assumes
natural grouping to consider because signed as collections of data and the the instance parameter will either
an application, which includes a class set of allowable operations on that provide information for the opera-
representation of a concept, will data. Therefore, the interface oper- tion of that function or the instance
usually need to include instances of ators of a class are inward-looking in will be modified by having one of its
a set of classes in order to fully imple- the sense that they are intended to ac- interface functions invoked.
ment the concept. Wirfs-Brock [29] cess or modify the internal data of the Strong Cohesion. A class is a natu-
defines a subsystem grouping and class. This leads to fewer connections rally cohesive module because it is a
the work of Johnson, reported in between classes. model of some entity. Object-
the Wirfs-Brock article describes Interactions between classes come oriented style guidelines require that
frameworks as other approaches to from two sources. The component for a function to be a member of a
grouping classes. These groupings relationship discussed previously class it must either access or modify
collect classes which as a group form results in a coupling between the two data defined within the class.
an abstraction. For example, the classes. If an instance of class A is The inheritance mechanism could
concept of a linked list might be declared within the implementation be viewed as weakening the cohesion
represented by three classes: a class of class B, then instances of class B of the module. The data and func-
that is the list itself; a class that contain an instance of class A in their tions inherited from another class
describes the links; and a class that implementation. Operators of class B form a natural group separate from
defines iterators for the list. In- send messages to (invoke the inter- those data values and functions
dividually the classes are not very face operators of) the instance of class defined within the new class.
abstraction by parameterization. oriented languages also supports ex- operator was designed. Thus a new
Object-oriented langwages support tensible designs. Figure 14 shows a feature is added with little or no
both of these meth,ods to varying simple inheritance hierarchy. Con- modification to the remainder of the
degrees. sider the operator x, shown in Figure application.
Abstraction by specification Integrable. The object-oriented de-
[
abstracts the specification of an entity sign process produces designs which
from its implementation. This type facilitate the integration of individual
of abstraction is supported by vir- pieces into complete designs. The
A
tually every object..oriented lang- narrow clearly defined interface of
csib
uage. The public interface of a class a class supports integration with other
constitutes the specification of that software components. The set of
class. The interface specifies the allowable operations and their
legitimate operators of the data con- B C D required parameters are easy to iden-
tained in instances of the class. In t* The narrow interface corresponds
most object-oriented languages, the naturally to the observable behaviors
implementation of these operators of the real-world entity modeled by
and the exact representation of the E F the class. The interfacing of two
class’s data elements are hidden from bb classes then is a model of the natural
access if not from the view of those interactions of the two entities.
outside the class definition. Objects are also very integrable at
provides operators for copying, con- the new class. This technique is tools that facilitate the location and
catenating, and, perhaps, even nonintrusive in that the existing code use of specific classes. The article by
editing the string value. is not modified. The new code in the Gibbs et al [6] in this issue discusses
Inheritance provides two levels of subclass can not cause the existing the problem of class management.
support for reuse. As part of the high- code to “break.” The inherited code
level design phase, inheritance serves is included in the new definition Peslgn Gulclellnes
as a means of modeling generaliza- automatically as the new class defini- In any object-oriented application,
tion/specialization relationships. tion is compiled. Any modifications instances of classes make up the ma-
These relationships appear in the to the original class, bug fixes or jority of the system and, if a pure
form of classifications. A chair may feature additions, are incorporated object-oriented approach is used, all
be viewed as a special type of fur- into the newer class at the next com- of the system consists of instances of
niture as well as a general description pilation. This technique allows a class classes. Therefore the design of the
of the more specific categories of to serve as the basis for many new individual classes has a major impact
rocking chairs, straight chairs, and definitions without propagating the on the overall quality of the applica-
reclining chairs. This high-level use errors of the original definitions tion. In this section a set of guidelines
of inheritance encourages the devel- throughout the system. is presented for the design of classes.
opment of meaningful abstractions Much research focuses on support The intent is to illustrate the factors
which, in turn, encourages reuse. for reuse. Several of the research ef- which should be considered when
Often in actual design the forts presented in Wirfs-Brock [29] designing a class without discussing
presence of mid-level abstractions include consideration of reuse. Reen- each guideline in detail. Figure 16
class. The sixth guideline is intended the object-oriented paradigm relies subset. Generalization supports the
to reduce, and perhaps eliminate, much more heavily on the use of sup- exploitation of commonalities be-
global information. Any information porting tools and environments tween classes. When two or more
needed by one class should be ex- compared to procedural design tech- classes are representing overlapping
plicitly passed to it in a parameter niques. This section presents in- sets of attributes, the common attri-
from another class. Guideline formation about some existing butes may be factored out of both
number seven prohibits the use of in- support systems and considers how classes and used to create a new class.
heritance to develop the representa- these systems may look in the future. The new class then becomes the
tion of a new class rather than its Many of the features of support superclass for those previously over-
interface. The preferred method for systems discussed here are not lapping classes. The inheritance
utilizing an instance of a class as part limited to the object-oriented do- mechanism of an object-oriented lan-
of the representation of another class main, but characteristics of object- guage implements both of these tools.
is to declare an instance of the sup- oriented design make particularly Specialization does not require
porting class in the representation of good use of the support provided by any modification of existing defini-
the newly designed class. Finally, the such an environment. tions. The new definition simply in-
last guideline encourages the cludes a reference to the existing one.
designer to develop inheritance Conceptual mo1s Generalization usually does require
structures of classes which are We have already described a number modification of existing definitions.
specializations of an abstraction. of conceptual tools for object- The definitions and declarations that
These abstractions lead to more oriented design. We will summarize are common among the classes are
linked list, by separating the list Users accessing a class in order to use models mentioned previously. An
iterator into a separate class, we are it as the basis for a new class delini- E-R Diagram provides a very flexi-
able to have multiple iterators on the tion may need more information ble framework in that it can capture
same list at the same time. than those users simply creating any relationship that exists between
No syntactic unit exists that in- instances from the definition. In classes. Excelerator provides an in-
dicates this relationship. This is the particular, some languages give tegrated data dictionary which allows
most important place to apply a tool operators written in the subclass much information about the classes
for support. The designer should be access to some or all of the data or and the relationships to be stored,
able to designate clusters in the soft- protected operators declared in the managed, and manipulated. A num-
ware base. If a user calls up the linked superclasses. ber of other existing computer-as-
list class, the environment should be The person creating the subclass sisted software engineering (CASE)
able to inform the user that these may need to see the data declarations tools support the development of the
other class are probably of interest as well as the interface for the E-R diagrams.
as well. class(es) being accessed. Some of this Most of these tools do not
These conceptual tools are very “data” are actually instances of other “understand” the object-oriented
useful in the design process. They classes declared as part of the paradigm. That is, they do not treat
provide guidelines for the design and representation of the current class. the application-specific relationships.
direction for the designer. Most ex- This implies that the user may need such as is-employed-by, any differ-
isting development environments re- access to definitions for these classes ently than the paradigm-specific re-
The designs developed in Software the relationships that exist between ImDlementing an object-
Through Pictures can be “brought to entities in the problem space. These Orlented Design
life” using the automatic code relationships represent the interac- The software community has long
generation facilities. Unfortunately, tions between complex entities and as realized that iteration is inherent in
the product does not support genera- a result are infinite in variety This re- the software life cycle. Since the soft-
tion in any object-oriented language. quires the flexible approach of the ware development team will be con-
It does provide code generation in entity-relationship semantic data stantly moving back and forth across
Ada, C, and Pascal. The code is not model that allows user-defined rela- the different phases, the joints be-
managed or manipulated by the en- tions rather than a limited number of tween what we have traditionally
vironment. Because the system does “standard” relations. The result at called analysis, design and imple-
not provide low-level design support, this level is a complex structure of mentation should be seamless.
the designer has very little control dependencies. Many environments Therefore it is important to have
over the code that is generated. allow the designer to draw this object-oriented languages and
class/application structure in the development environments that
form of E-R diagrams or some other directly support the object-oriented
Tools for implementation. A num-
notation and retain only the at- design paradigm and that make a
ber of languages are accompanied by
tributes of the picture rather than the smooth transition between design
toolkits which support the low-level
interconnections. This is insufficient. and implementation.
design and implementation process.
The tool should provide a represen- The object-oriented design para-
Smalltalk provides an integrated en-
tation for this structure which can be digm exists independently from any
56
I I I I I Ill1 I I I I I 1111111111~ ONIECT-ONINNTND DES181
58 September 1990/Vo1.33,No.9ICOYYUNICLlIONSOFTREliCY
I I I I I I I
a class-object. This object is not a database system. digm are not realized on such
class instance, but more like an acces- In Smalltalk and CLOS the entire projects, managers will become dis-
sible class descriptor. Another way of current execution state can be saved illusioned with the “object-oriented”
looking at it is that each class has a to disk. Yet, individual objects cannot approach.
corresponding meta-class that be saved to an external file through Proponents of hybrid languages
describes the class. A class-object is the facilities of the basic language. see them as a natural migration path
an instance of this meta-class. Uses Other languages provide object i/o into the paradigm. Programmers
for such a class-object were given in to disk in the same way that Pascal skilled in the base language can im-
that section. and COBOL provide record i/o. An mediately use the object-oriented
In Smalltalk all run-time entities environment can add this function- version and gradually learn the new
are objects. Even integers are in- ality without altering the language features and paradigm. Proponents
stances of the integer class. Other definition or adding keywords by also claim that not all problems are
languages allow some primitives such adding an object storage manage- best solved by a single tool, thus the
as an integer to be implemented in ment class to the class library. An ob- availability of multiple paradigms is
the traditional way. This saves mem- ject needing persistence would then desirable.
ory space and execution overhead as inherit from the “storable” class.
every integer does not have to have a This is the approach taken by Eiffel. Hlstory Lessons
pointer to its class descriptor, etc. The OOPS class library [7] uses a There is much that has been learned
Other systems treat integers concep- single root class to provide basic per- about software develoment that is or-
tually as objects, but handle them sistence capabilities and guarantee thogonal to the object-oriented para-
59
sidering a definition that includes ob- Zompi, R. PROTOB, a hierarchical ob- 21. Sciore, E. Object specialization. ACM
jects, classes, and class inheritance, ject-oriented CASE tool for distributed i%n.r. I$ @St.,7, 2 (April 1989), 103-122.
systems. In ESEC ‘89, Zd European Software
we have tried to focus on a set of con- 22. Snyder, A. Encapsulation and inheritance
Engineering Confemce Lecture Notes in Com-
cepts that we view as a paradigm in object-oriented programming lan-
puter ScienceRO.387, Springer-Verlag, 1989.
separate from the object-based para- 2. Boehm, B. A spiral model of software
guages. In Proceedings of OOPSLA (1986),
digm being supported by the Ada development and enhancement. Computq
pp. 38-45.
and Modula-2 communities. 23. Sommerville, I. Software Engineering.
(May 1988), 61-72.
The design philosophy of the Addison-Wesley, 1989.
3. Cardelli, L. and Wegner, P. On under-
24. Tsichritzis, D., Ed. Active Object Enoiron-
object-oriented paradigm takes a standing types, data abstraction, and
me&. Centre Universitaire D’Informa-
modeling point of view. This allows polymorphism. Comput. Sure. 17, 4 ACM,
tique, Geneve Switzerland, 1987.
the designer to work with one ap- N.Y. 471-522.
25. Tsichritzis, D., Ed. Object OrientedDevelop-
proach which begins in the problem 4. &ad, P. and Yourdon, E. Object-oriented
ment. Centre Universitaire D’Informa-
Analysis. Yourdon Press, 1990.
domain and transitions naturally tique, Geneve Switzerland, 1989.
5. Cox, B. Object-oriented Pmgramming: An
into the solution dornain. By build- 26. Wasserman, A.I., Pircher, P.A., Muller,
Evolutionary Apprwch. Addison-Wesley,
ing a model of the problem into the New York, 1986.
R.J. Concepts of object-oriented struc-
application system, the resulting de- 6. Gibbs, S., Tsichritzis, D., Casais, E.,
tured design. In Proceedings of TOOLS ‘89
sign is more responsive to changes in (1989), pp. 269-280.
Nierstrasz, O., Pintado, X. Class man-
knowledge about the problem situa- 27. Wegner, P. Dimensions of object-based
agement for software communities. Com-
language design. In Proceedings of the Con-
tion. The modularity of these designs mun. ACM 33, 9 (Sept. 1990).
ference on Object-OrientedSystems, Languages,
and information-hiding capabilities 7. Gorlen, K. An object-oriented class li-
60 Septcmber1990/Vo1.33,No.9/COYYUNlC*TIOWSOFT"EliCY