Object oriented software development using Java principles patterns and frameworks 2nd Edition Xiaoping Jia. 2025 scribd download
Object oriented software development using Java principles patterns and frameworks 2nd Edition Xiaoping Jia. 2025 scribd download
https://ebookultra.com/download/object-oriented-software-engineering-
using-uml-patterns-and-java-2nd-edition-bernd-bruegge/
https://ebookultra.com/download/foundations-of-object-oriented-
programming-using-net-2-0-patterns-1st-edition-christian-gross-auth/
https://ebookultra.com/download/object-oriented-software-
engineering-7th-edition-stephen-schach/
Object Oriented Design with UML and Java 1st Edition
Kenneth Barclay
https://ebookultra.com/download/object-oriented-design-with-uml-and-
java-1st-edition-kenneth-barclay/
https://ebookultra.com/download/java-the-uml-way-integrating-object-
oriented-design-and-programming-else-lervik/
https://ebookultra.com/download/applying-uml-and-patterns-an-
introduction-to-object-oriented-programming-2ed-edition-larmen/
https://ebookultra.com/download/scientific-software-design-the-object-
oriented-way-1st-edition-damian-rouson/
https://ebookultra.com/download/design-patterns-explained-a-new-
perspective-on-object-oriented-design-2-ed-edition-shalloway/
Object oriented software development using Java
principles patterns and frameworks 2nd Edition Xiaoping
Jia. Digital Instant Download
Author(s): Xiaoping Jia.
ISBN(s): 9780201737332, 0201737337
Edition: 2
File Details: PDF, 91.39 MB
Year: 2003
Language: english
Obje_ct-O_rie_11te____ __._eRI_NcLeLEs__ _ _
Xiaoping Jia
DePaul University
~
.
Addison
WPsl<•y
Acces the latest information about Addison-Wesley titles from our World Wide Web site:
www.aw.com/cs
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in this book, and Addison-Wesley
was aware of a trademark claim, the designations have been printed in initial caps or all caps.
Toe programs and applications presented in this book have been included for their instructional
value. They have been tested with care, but are not guaranteed for any particular purpose. The
publisher does not offer any warranties or representations, nor does it accept any liabilities
with respect to the programs or applications.
Credits: Figure 1.2: Kruchten, Rational Unified Process 2nd ed., Fig. 2.2 (p. 23), © 2000
Addi.son Wesley Longman Inc. Reprinted by permission of Pearson Education, Inc. Figure
3.1: Riggs et al, Programming Wireless Devices w/Java 2 Platform, Micro Edition, Fig. 2.1
(p. 8), © 2001 Sun Microsystems Inc. Reprinted by permission of Pearson Education, Inc.
For information on obtaining permission for the use of material from this work, please submit
a wrinen request LO Pearson Education, Inc., Rights and Contracts Department, 75 Arlington
SL, Suite 300, Boston, MA 02116 or fax. your request to 617-848-7047.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system,
or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording,
or otherwise, without the prior written permission of the publisher. Printed in the United States
of America.
2 3 4 5 6 7 8 9 10- HT-05 04 03
To Ai-Ling and Robin
B•,ZiiiiiH
Preface xv
Glossary 653
References 663
Index 667
Object-Oriented Software
Development
CHAPTER OVERVIEW
In this chapter, we provide an overview of object-oriented software development. We
start w ith a general d iscussion of software development processes and the desi@ble
qualities of software products. Next, we discuss what makes software development
difficult and the difference between software engineering and other more established
engineering practices. Then we take a close look at ite@tive software development
processes, including the Rational Unified Process (RUP) and Extreme Programming (XP).
1
2 ■ Object-Oriented Software Development
• On January 15, 1990, the AT&T long-distance telephone network broke down,
interrupting nationwide long-distance telephone services in the United State f or
more than 8 hours. An ill-placed break statement in the switching software,
written in the C language, was to blame for the breakdown.
• On June 4, 1996, the maiden flight of the new and improved Ariane 5 commu
nication satellite launcher developed by the European Space Agency exploded
37 seconds after liftoff. An incorrectly handled software exception resulting from
converting a 64-bit floating point to a 16-bit signed integer caused the disaster.
• On June 8, 200 I, a software problem in the new trading software installed
overnight for the New York Stock Exchange caused failures in trading on half of
the floor of the exchange and forced the NYSE to shut down the entire trading
floor for more than an hour.
Although uch cata trophic failures are rare, minor glitches are common in almost all
oftware. In other words, buggy software is the nom1.
However, the state of oftware development practice i far from the "software
crisis" many have proclaimed in the past. Advances in many aspects of software de
velopment methodologies and software engineering proce ses have made it po ible
I? develop many large-scale software systems that perform as expected most of the
time. We are not capable of delivering nor required to deliver 100% reliable software
The question i , How good i good enough?
1.1 The Challenges of Software Development ■ 3
Complexity The software ystem being developed today are often very large and
complex. Complexity is dictated by the problems the sy tem are intended to solve
and the services they are intended to provide. From the engineering perspective, both
requirements are often beyond the control of software developers. The complexity
involved in a large-scale software system is so great that no individual can comprehend
every detail of the system. To build such a complex sy tem, it mu t be broken down
into manageable parts and requires the cooperative effo11s of a team of developer
rather than the efforts of an individual. Methodologie , techniques, and tool that
work well for small systems developed by individuals usually are not effective for
large systems developed by tean1s.
High User Expectations In the past, whe n computer were mainly u ed in univer-
sitie , research institutions, and large corporation , the majority of software ystem
users were scientists and engineer who had the technical kill 10 handle glitche
they might encounter while using the sy tern . Today, computer are used in home ,
school , and businesses of all size , and are used for plea ure a well a for work.
The majority of today's software u er are nontechnical, ordinary people. Computer
oftware products are con idered more and more like con umer producl and are ex-
pected to perfom1 with the a me depe ndability as hou ehold appliances. Occa ional
glitche that once were con idered acceptable are now intolerable. Software Y tern
are expected to be " bug-free ," but uch perfection i next to impossible.
I>
AN ENGINEERING PERSPECTIVE
..i
The term software engineering was coined al a NATO workshop in 1968. It repre
ented an aspiration to m ch e practice of software development on a solid scientific
foundation and to attain the level of reliability and productivity associated with well
e tabli hed engineering di cipline , uch as civil and mechanical engineering.
Software engineering is �jneering discipline concerned with al�
developing and delivering high-quality and use�i:�ecti-ve-manner.
Software engineering defines the various activities in the software development and
the products, or deliverables, a sociated with these activities. Software engineering
also define the sofnvare development processes, which define the order for carrying
out the development activities and the criteria for the deliverables of the activities.
components, and detail design, which is primarily concerned with the solutions to
each component. Software designs are often documented using various diagrams.
Integration and System Testing The individual components or units are integrated
and tested as a whole to ensure that the entire software system functions properly with
respect to its specification.
The most well-known software development process is the ·<waterfall" model illus-
trated in Figure 1.1, which has been the de facto standard of the software development
process. In the waterfall model, the development activities are carried out in succes-
sive phases linearly: requirements analysis, design, implementation and unit te ting,
integration and system testing, and maintenance. A phase i the pan of time between
two major milestones of the process in which a well-defined et of objective are met,
artifacts are completed, and decisions are made whether to move into the next phase.
In principle, the deliverable of each phase must be approved (" igned off') before the
Figure 1.1
Requirements
l
analysis
The waterfall model
of software devel- +
I
I
opment. '---- - Design
+
,' _____
I
i
Implementation
and unit testing
+
I
I
i
Integration and
·----- system testing
+
I
,_____
I
Maintenance
as
next phase can begin. The rationale is that changes to the requirements specification
cost much less to implement in the requirements analysis than in the later phases. The
later the phase in which a change to the requirements is introduced, the more it costs.
So the goal is to minimize changes after the documents are delivered. This requires
that the tasks of each phase be completed thoroughly, and that the deliverables of each
phase be frozen once they are delivered and approved.
However, the waterfall model is not realistic. It is very common that changes
occur during every phase of the development process. The changes may come from a
number of sources: errors or faults of the specification and design may be discovered
during implementation; assumptions made in design may be proven false during
y tern testing; some features requested by the customers may be proven to be too
low, excessive in resource consumption, or infeasible during system testing; and
user needs and requirements may have changed after the requirements analysis is
completed. Therefore, in practice, it is often necessary to have several iterations of
the phase in the waterfall model. However, one of the major shortcomings of the
waterfall model is that it does not facilitate such iterations.
There are several alternative software development processes that are designed
to carry out the software development activities in an iterative fashion. The itera-
tive software development processes are becoming popular and gaining acceptance
in practice, partly because of the wide acceptance of object-oriented development
methodologies, which are especially suited to iterative development. We will discuss
two of the common iterative development processes in Section 1.4.
N?t all of these desir~ble qualities are attainable at the same time, nor are they of
equal importance. A crucial part of software development is dealing with the trade.-
o~s amo?g these different qualities to achieve a reasonable balance. Obviously, the
obJect-on:nted developm~ t approach cannot directly improve aJI these qualities. It
~cuse~ primarily O!!_improving_the_!!laintainability and reusabj lity of software sys- ,
terns.Maintainability should be the focuo fife development process for three main
reasons. First, for software systems with long lifetimes, maintenance co ts will far ex-
ceed initial development costs. It is imprudent to compromise maintainability because
any savings that may result ini tial ly will undoubtedly be dwarfed by maintenance cost
penalties over the long run. Second, current development technology does not yield
high reliability in the initial release of software sy tern . Reliability i u ually attained
through repeated corrections during the development pha e and throughout the life-
times of software system . Software system reliability can be everely hampered by
poor maintainabi lity. Third, high maintainability require flexibility in the de ign and
implementation of software systems. Such flexibility facilitate the kind of incremen-
tal development that enhances reliability, u efulne s, and u er friendline . a well as
the ability to contain costs.
Several factors contribute to the maintainability of oftware y tern :
These fac tors me the fo us of our discu. sion of methods and techniques in later
chapters.
8 ■ Object-Oriented Software Development
Analysis of Designs
Over the centuries, craftsmanship clearly has proved capable of building magnificent
tructures. such as the Egyptian pyramids, Roman aqueducts, and Notre Dame Cathe-
dral. However, modem engineering offers assurance, predictability, and efficiency
that craftsmanship cannot match. One of the key differences between engineering
and craftsmanship is that the success of engineering projects can be assured before-
hand through scientific analysis of their designs, whereas the success of craftsmanship
projects is attained through trial and error during current and prior construction.
Civil engineers depend on mechanics to help them predict with confidence before
construction begins that a newly designed bridge or building will stand and function
as it is supposed to. Aerospace engineers depend on aerodynamics and simulation to
help them predict with confidence before it is built that a newly designed airplane
will fly.
In contrast, software developers largely depend on testing and debugging (i.e.,
trial and error) to establish confidence in their products. Software development is
like building modern skyscrapers with craftsmanship, with the success of software
development projects rarely assured beforehand.
Nonrecurrence of Failures
Failures, ometimes catastrophic, also occur in well-established engineering fields.
Perhaps one of the most spectacular failures in the history of engineering was the
collapse of the Tacoma Narrows Bridge in 1940. Its design was unconventional and
innovative, and the bridge was dramatic and elegant in appearance. Careful analysis
w~s per~o~ed to en ure that the bridge would behave well under its own weight
with ant1c1pated traffic load and winds as high as 45 miles per hour. However the
~esigner did nor fore~ee that the slender ~ridge deck would act like an airplane ~ing
ma moderate crosswind of less than 40 miles per hour, which twisted the bridge apart.
A oo~ a th~ cause of the collapse _was known, 1~easures were developed to prevent
such failures in the fu1ure. Hence, rn well-established engineering fields, the same
type of failure is rarely repealed.
1.3 Object Orientation ■ 9
In software development, the same types of failures recur all the time. Few
practical measures can be taken to ensure the absence of certain types of faults in
software systems. The sad truth about software development is that no one can ensure
that the type of failure that occurred in Ariane 5 will never occur again.
Codification of Knowledge
The success of well-established engineering fields is due largely to the accumulation
and codification of knowledge and the reuse of prior solutions. Design knowledge
and solutions often are organized and presented in manuals and handbooks to make
common and routine design not only easier and faster, but also more reliable, depend-
able, and manageable. Designers often find solutions inhandbooks and then adapt and
assemble the solutions to their specific design problems. Only rarely are original and
innovative solutions needed. Usually, the codified knowledge includes what to avoid
as well as what to do.
In software development, although a lot of design knowledge and experience has
been accumulated, very little has been systematically codified. Without the benefit of
prior design solutions, each design of a software system i treated as an original.
Therefore, it is no surprise that software design is difficult, time-consuming, and
unreliable.
Thus, software development is quite different from the traditional engineering
disciplines. At best, it is an immature engineering discipline. For software develop-
ment to become a true engineering discipline, software developers must have mech-
anisms to carry out the analysis of designs, ensure nonrecurrence of knm,vn failures,
and codify design knowledge.
The main goal of software development i to build soft\ are y tern that provide
services to people and enhance their abilitie to . olve problem in the real world. A
software system usually con i ts of two e ential component : a model, which is a
representation of a pertinent part of the real world, and an algorithm, which captures
the computation involved in manipulating or proce ing the model.
Software system
Abstraction
Model Algorithm
Interpretation
10 ■ Object-Oriented Software Development
The real world is enonnous and complex. Many of its aspects are fuzzy, unknown,
or intangible. 1n contrast, the programming models used in software systems must be
precise ~d relatively small. A model is necessarily a~ ~bstractio11 of the real world.
It capture only the essential and relevant charactenst1cs of the real wo_rld from a
particular perspective and ignores others. Models are intended to be manipulated or
proce ed. and their behaviors should mimic those of the rea~ worl_d to reflect the
cho en perspectives reasonably accurately. The results of mampulations can be fed
back to the real world through i11terpretatio11 (i.e., the assignment of meanings to the
entitie in the models) and often represent solutions to real-world problems.
Programming languages are the main tools used by software developers to de-
scribe computer models. The evolution of progranuning languages and progranuning
methodologies is driven by the need to build more and more sophisticated and ef-
fective models. That need in turn is driven by the ever-increasing power of modern
computers and the desire to utilize this power.
One of the fundamental problems in software development is, How does someone
model the real world? The answer largely depends on the problems to be solved. One
way to look at the evolution of software development methodologies is through the
changing views of programming models.
In the 1950s and 1960s, the focus of software developers was on the algorithm. As
a result, the main concerns at that time were solving computation problems, designing
efficient algorithms, and controlling the complexity of computation. The models used
were computation-oriented models, and the decomposition of complex systems was
primarily based on control flo w.
In the 1970s and 1980s, different types of models emerged to address the com-
plexity of the data being processed. These systems were centered on data entities
and data fl ows, with computation becoming a secondary concern. The models used
were data-oriented models, and the decomposition of complex systems was primarily
based on data flow.
Object-oriented models represent a balanced view of the data and computation
aspects of software systems. Object-oriented models are composed of objects, which
contain data and the associated computations. The decomposition of complex systems
is based on the structure of objects, classes, and the relationships among them.
The origin of object-oriented software development dates back to the late 1960s. A
computer simulation language called Simula wa,; the first programming language that
included ome important features of object-oriented programming, such as class. The
fir t full -blown and perhaps the best known object-oriented programming language
was Smalltalk, developed by Xerox PARC in the I 970s. Object-oriented technology
grew tremendously during the 1980s, with the emergence of several more sophi _
1.4 Iterative Development Processes ■ 11
■ Each iteration is relatively small and can be completed in a relatively short period
of time.
■ Each iteration results in a release of an executable product or component, which
is a part of the final product.
The final product is developed incrementally from iteration to iteration.
5. Design model: Establishes the vocabulary of the problem and its solution
6. Process model (optional): Establishes the system's concurrency and synchro-
nization mechanisms
7. Deployment model: E tablishes the hardware topology on which the system is
executed
8. Implementation model: Establishes the parts used to assemble and release the
physical sy tem
9. Test model: Establishes the paths by which the system is validated and verified
The RUP i use case driven . Use cases defined for system requirements are the
foundation for all other development activities, including design, implementation,
and te ting. The RUP is architecture centric. The main focus of early iteration of the
development process is to produce and validate an executable architecture prototype,
which gradually evolves to become the final system in later iterations.
The process structure of the RUP can be illustrated in a two-dimensional chart
as hown in Figure 1.2. One dimension represents the time in terms of phases and
itera.tion . The other dimension represents the process work.flows. The chart shows
roughly the amount of time or attention devoted to each process work.flow during
various phases and iterations.
A process workjl.oH consists of a sequence of activities that produce a set of
anifacts, or deliverables, which can be project plans, design models, source code,
tests, and documentations. The RUP defines nine process work.flows:
Environment ~~====::~r;::;::~~==~:,,-::=======-4r========--
lnitlal
~ - - - ~ - ~ ~ #1
I
IElabllElabl 1cons111c onstj[Const j
#2 #N
[l'ra;,1
~ #2
1Tran \
Iterations
1.4 Iterative Development Processes • 15
4. Implementation: Takes into account software development, unit test, and integra-
tion
5. Test: Describes test cases, procedures, and defect-tracking metrics
6. Deployment: Covers the deliverable ystem configuration
7. Con.figuration management: Controls change to and maintains the integrity of a
project's artifacts
8. Project management: Describes various strategies of working with an iterative
process
9. Environment: Covers the necessary infrastructure required to develop a system
Each phase is further broken down into one or more irerations. Each iteration goes
through the various process workflows (de cribed earlier) and i a complete develop-
ment cycle that results in the release of an executable product. The phase serve as the
controlling framework of the iterations. Iteration in different phases have different
emphases on process workflows as illu trated in Figure 1.2. For example, iteration
in the inception phase focus more on business modeling and requirements, while it-
erations in the construction phase focu more on implementation and configuration
management.
refactoring to maintain and improve qualities and to facilitate changes and enhance-
ments.
The core of XP consists of the following key practices:
Planning game: Start with a simple a plan for each iteration, and continually
refine the plan as necessary.
Frequenr and small releases: Make frequent and small releases starting as early
as possible. Each iteration, that is, the duration for producing a release,
bould not be longer than a few weeks.
Metaphor: U e metaphor to start development and communicate with the
customers.
Simple design: Make design as simple as possible. Refactor later if changes are
nece sary.
Test first: Write unit test before writing code.
Refactoring: Refactor to make the system simpler and clearer or to reduce
duplication.
Pair programming: Write all production code in pairs.
Collective ownership: Anyone may change code anywhere in the system to
improve it.
Continuous imegrarion: Integrate as soon as a task is complete.
40-hourweek: Teams are more productive if the members stay fresh and energetic
than if they work overtime.
On-sire customer: Have a customer available on-site and full time.
Coding standards: Adopt common standards and conventions for naming, source
code fonnaning, documentation, and so on.
Undoubtedly, some of the practices are unique to XP, such as pair programming.
Extreme programming and RUP share a lot in common. In some sense, XP can be
viewed as a minimalistic form of the RUP. One of the key differences between the two
is that the RUP emphasizes building object-oriented models using modeling notations
defined in UML, while XP emphasizes producing executable code. However, building
object-oriented model using UML is often done in XP as welJ. Several commonly
used notations of UML will be discussed in Chapter 2. Unit testing and continued
integration will be discus ed in Chapter 6. Refactoring will be one of the main topics
of Chapter 7.
CHAPTER SUMMARY
Brook , F. P. (1987). "No Silver BuUet- E ence and Accident of Software Engi-
neering," IEEE Software 20(4).
Jacob on. I., G. Booch, and J. Rumbaugh ( 1999). The Unified Sofnvare Development
Process. Addi on-Wesle .
Kruchten, P. (2000). The Rational U11ified Proass. A11 Imrodu tio11, 2nd ed. Addison-
We ley.
EXERCISES
1.1 Search the Web or librarie to find out detail of 1.3 Search the Web or libraries to find out whether
some of the catastrophic failure of computer it is permissible to use software engineer as a
systems who e cause ha,·e be-en attributed to professional title without ce1tification in your
software failures. including the one mentioned country or state, and what the rationale is.
in this chapter.
1.2 Search the Web or librarie to find out details
of some failed oftware development projects
and the cause .
Object-Oriented Modeling
Using UML
CHAPTER OVERVIEW
In this chapter, we discuss the basic principles, concepts, and techniques of object-
oriented modeling. We introduce a number of commonly used notations in the Unified
Modeling Language (UML), including class diagrams, object diagrams, sequence dia-
grams, and use case diagrams. We conclude the chapter with a case study of object-
oriented analysis and modeling.
In thi ection, we di u, the ba i con ept and the prin iple , of object-oriented
development. \Ve also introduce some ~ imp le graphi al notations in the Unified
Modeling language (U IL) (Booch et al .. 1999] 1 for des ·ribing obje t-orientcd
models. We u e a sub ·et of U IL notations with minor adJptati ns in synt, x for the
ake of con, isten , ith Ja a.
l. Ul\ IL is a stand:.ml for objc~t-orienteJ moJ ling no1~11i 1ns cnJol'\ed by the Object I\ 1:magcmcnt Group
(0 •IG), nn indu ·trial ron ·t,rtium on obj~ct tc~hnologics.
19
-
20 ■ Object-Oriented Modeling Using UML
Each object has a unique identity. The identity of an object distinguishes the
object from all other objects. The state of an object is composed of a set of fields, or
arrribules. Each field bas a name, a type, and a value. The behavior of an object
is defined by a set of methods that may operate on the object. In other words, a
method may access or manipulate the state of the object. Methods are sometimes
called operations, and we consider these two tenns to be synonymous. Each method
al.so bas a name, a type, and a value. The type of a method consists of the return type
and the list of parameter types of the method. The return type can be void if the
method does not return a value. The value of a method is the implementation of the
method often expressed as a sequence of statements, in languages like Java or C++.
The features of an object refer to the combination of the state and the behavior of the
objecL
Two objects are equal if their states are equal, that is, if the values of the
corre ponding fields of the two objects are equal. Two objects are identical if they are
the ame object, that is, if they have the same identity.
The value of the field of an object are mutable. Those methods of an object
chat do not modify the slate of the object are called accessors, and those methods
of an object char could modify the state of the object are called mutators. A mutable
object is an object whose state may be modified by some of its methods. A mutable
object may have different states at different times. An immutable object is an object
2.1 Principles and Concepts • 21
whose state may never be modified by any of its methods, that is, an object that has
no mutators. The tate of an immutable object remains constant. Objects are usually
mutable. However, immutable objects are quite useful too.
A class defines a template for creating or instantiating its instances, that is,
objects. The terms object and instance are often interchangeable. The class from
which an object is created is referred to a the class of the object, and the object
is referred to as an instance of the clas . In mo t object-oriented languages, including
Java and C++, in tead of defining the feature of individual objects, the features of
objects are defined in the class that instantiate the object . Specifically, a class defines
(1 ) the names and types of all fi eld and (2) the name . type , and implementations of
all methods. The values of the fields are not defined or fixed in the class definition. The
values of the fields are mutable. Each instance of the clas · ha its own state. Different
instances of the class may have different state . The implementation of methods are
defined in the class definition and are therefore fixed for a given object. In other word ,
the values of method of an object are immutable.
Let's look at a simple cla Point that repre ent points in a two-dimensional
space. The Java code defining the class is shown on the right-hand ide.
The Point class defines two field : x and y, and one method: move O. The type
of both fields is i nt . The return type of move () i void and the Ii t of the p:irarneter
types of move() i (int, i nt ), since it take two parameter both of type int.
method,
The bon m comparunent contains the declaration. of the methods
... of the cla :
methodm
If, in ome context, the detail of the field - and method of the la s i. not important,
one may omit both the middle and the b tt m l'0mpa.rtments.
22 • Object-Oriented Modeling Using UML
The visibility, or accessibility, of fields and methods defines the scope in which
features of classe are accessible. Visibility can be one of the following:
The acces ibility of features will be discussed in more detail in Section 4.4.1. T he
Java and UML syntaxes for visibility are as follows:
public public +
protected protected #
package
private private
2. In 1his book. we use the following convention to defi ne syntax: the notation Foo (e g •n , 1 ) d t
. I bI . I bol h . f .., •1/ e eno es a
nonlcnmna ~ym o ; 1em11na sym s ~re~ own 111 bold ace Courier font (e.g., •). The entities between
square brackets ! J (e.g., (T)peJ) arc opllonal.
J. Packages arc discussed laler in this section fp. 25] and in Section 4.5 Ip. 134].
• I•
2.1 Principles and Concepts • 23
The multiplicity specification of a field specifies whether an object may have mul-
tiple occurrences of the field. The multiplicity specification is defined in Section 2.2.2
[p. 33].
Each parameter of a method can be specified using the Java syntax as follows:
Type Name
Name: Type
Field declarations
Date birthday (Java syntax)
birthday : Date (UML syntax)
Method declarations
void move ( int dx, i nt dy) (Java yntax)
-move (dx: i nt, dy : int) (UML ynta"<.)
The Point cla s shown earlier can be repre ented in UML as follm • at different
levels of detail.
Point
private int x
private int y
public void move(int dx, int dy)
-
24 ■ Object-Oriented Modeling Using UML
Point
-x:int
-y:int
+move(dx:int, dy:int)
Abbreviated fonns:
Point
X
y
move()
There are a number of variations for the contents of the top compartment:
• objectName
Omission of the colon and the class name denotes an object named obj e ctN ame
whose class is of no interest.
• : ClassName
Omission of the object name denotes an anonymous object of class ClassName,
which can be identified only through its relationship with other objects.
The fields and their values in the bottom compartment are described with the
foUowing syntax:
Field• Value
The bottom compartment may be omitted altogether if the attributes and values of an
object are of no interest
2.1 Principles and Concepts • 25
For example, instances of the Point class, with the states (0, 0) and (24, 40),
can be represented graphically as follows:
The Java code segment, on the right, shows the creation of the instances and the
assignment of the states.
Recipient pl
p1.move(10, 20) Method move()
Arguments (10, 20)
Packages
Classes are often grouped into a package. Package. an be organized into a hierarchy.
In other words, a package may contain cla e and -ubpackage . It i important
to point out that all clas e in the ame package mu t be clo ely related, since all
feature of a cla , except tho e that are private. are ac e ible to all cla e in the
ame pa kage. Detail. for u ing pa .kag ' in Java, ill be di cus ed in Section 4.5. l .
-
26 ■ Object-Oriented Modeling Using UML
(a)
2.1.2 Principles
Modularity
One of the fundamental principles of the object-oriented approach is the principle of
modularity. It is intended to control the complexity of large-scale systems through the
use of the divide-and-conquer technique.
Pri~ Modularity
A complex software system should be decomposed into a set of highly cohesive but
loo ely coupled modules.
■ each module is relatively small and simple (that is, hjghly cohesive); and
■ the interactions among modules are relatively simple (that is, loosely coupled),
ensuring that- by examining the module within, not without-each module will
be well-behaved and that, if all the modules are well-behaved, the entire system
also wiU be well-behaved.
Abstraction
In its purest sense, abstraction means separating the e ential from the none ential
characteristics of an entity. The result is a simpler but sufficiently accurate approx-
imation of the original entity, obtained by removing or ignoring the none enrial
characteristics. The abstraction principle in software development can be described
as follows:
Principle Abstraction
The behaviors, or functionalities, of a module bouJd be cbara terized in a uccinct
and precise description known as the co11tractual interface of the module. In other
words, the contractual interface capture the e en e of the behavior of the module.
The contractual interface is an ab traction of the module.
We can view a module a a senice provider and other module that u e the
services provided by the module as cliems of the module. \: e an view the contractual
interface as the service contract bet\ een the ervice pro idcr and it. clients.
service contract need only de cribe what e.rvi es ·ru1 be pro ided, not how the
service are to be provided. Therefore, de pite the fact that the rvice to be pro ided
are very complex, the , ervice ontract may be very imp le. ith a imple ervice
contract and an as uran .e by the . ervice provider of h noring the ontracl. the client
need only undectand the · imple contra t in order to u ·e the comp le , service .. The
contractual interfa e alto, s the client to u, e the . ervice , and not be oncemed with
the complexity of the er ice ·. In other , ord~. the comple. it of the module i hidden
within it.
Let us onsider the exrunpk of th telephone . The mechani m for providing
telephone . er ice i , a rather comp le. one. lt in olws routing and connecting calls,
28 • Object-Oriented Modeling Using UML
convening voice to electronic signals and back to voice, transmitting the signals. in
analog or digital mode, and possibly encrypting and decrypting the signals f~r secunt;
reason . However, telephone users (that is, the clients of a telephone service) don t
need to understand the mechanics of a phone system. All the users need to understand
i the manual that comes with the telephone set, which includes instructions on dialing,
speaking. and hanging up. The user's manual in this case is the contractual interface
of the telephone service, and it serves as an abstraction of the telephone service from
the user's perspective.
Encapsulation
A closely related and complementary principle is encapsulation, which stipulates that
the clients need know nothing more than the service contract while using the service.
Principle Encapsulation
The implementation of a module should be separated from its contractual interface
and hidden from the clients of the module.
Polymorphism
Several different service providers can honor the same contractual interface. More-
over, these service providers can be interchanged without affecting the clients. The
2.2 Modeling Relationships and Structures • 29
In this section, we introduce the UML class diagram for modeling the tatic tructures
of object-oriented software systems and various types of relation among the cJas es.
Class diagrams are the most common diagrams used in object-oriented modeling. A
class diagram consists of
■ a set of nodes that represent classes and interface ; and
■ a set of links that represent relationship among clas es.
2.2.1 Inheritance
4. The word poly111orphis111 ml!un · an i:nLity , ilh multiple~ m1 ·. In lhis particular context, it refer to a
conlructual inlcrfm:i: , ilh multiple interchangeable impkmcntntions.
--
■ The txtension relation between two interfaces. When interface 12 extends inter-
face l 1, interface 12 is known as a subinterface of interface l 1, and interface l 1
is known as a superinterface of interface 12.
■ The implementation relation between a class and an interfacq. When class C2
implements interface 11, class C2 is known as an implementation of interface
11, and interface 11 is known as an inte1face of class C2.
UML uses a different terminology for inheritance relationships. The extension relation
is also known as specialization, and the inverse relation is known as generalization
in UML. The implementation relation is also know as realization in UML.
Graphically, the inheritance relation is represented by a link from the subclass/
subinterface to the superclass/superinterface with a hollow triangle pointing toward
the superclass. The extension relation is represented by a solid link, and the imple-
mentation relation is represented by a dashed link, as shown in Figure 2.2. In class
diagrams, the regular class, field, and method names are shown in upright roman fonts,
as in MyClass. The names of interfaces and its methods are shown in italic fonts, as
in Mylnterface.
Conceptually, inheritance models the is-a(n) relationship in the real world; that is,
if C2 is a subclass/subinterface/implementation of Cl, then every instance of C2 is an
instance of Cl, and everything that applies to instances of Cl also applies to instances
of C2. The ex.tension relation between two classes is commonly associated with the
notion of reusing or sharing the implementation (that is, the fields and methods) of a
superclass by its subclasses. The extension relation between two interfaces represents
the expansion of the service contract. The implementation relation does not connote
reuse of implementations, but rather the implementation of a contractual interface by
a class.
As an example, let us consider the following set of classes that represent different
groups of srudents in a university. The class diagram is shown in Figure 2.3.
F"tgure 2.2
Superclass Superinterface Interface
6.
UML notation fOf'
lnhattana r~la-
tionships.
Subclass Subinterface Implementation
Figure 2.3
Student
Class diagram: in-
heritance relation
among classes rep- Nondegree Undergraduate Graduate
resenting student
groups.
Master PhD
Class Description
Levels of Abstraction
Cla. se and interface repre ent ab traction , and the inheritance relation hip orga-
nizes the cla ses and interfa e into different level of ab traction.
32 ■ Object-Oriented Modeling Using UML
1n other words, the superclasses represent more general abstractions and the
subclasses repre ent more specialized abstractions. Consider again the example of
tudents hown in Figure 2.3. The inheritance hierarchy shows different levels of ab-
straction of students in a university. The Student class represents the most general
ab traction of tudents, whereas its subclasses represent various specialized abstrac-
tions of tudents. The leaf classes (that is, classes with no subclasses) represent the
most pecialized ab tractions of students.
2. 2-2 Association
Figure 2.4
Class1I
- - - - ~ role
name
I Class2
role ~-----'
UML notation for
association rda-
tionship.
2.2 Mod~ing Relationships and Structures • 33
Figure 2.5
Student 1-•-_ _e_n_ro __
_ll_► -1
Course
Class diagram: as- advisee •
sociation relation-
ships.
• teach
1
1
Faculty
adviser
with Facult y and Student, respectively, in the association between Faculty and
Student . The role name may also have an optional vi ibility designator, that is +,
#, - ,or-.
The multiplicity specification is a comma-separated sequence of integer intervals.
An integer interval can be one of the following:
l . .u specifies a closed, that is, inclusive, range of integers from the lower bound
I to the upper bound u. Both the lower and upper bound are integer literals.
The upper bound may also be the asterisk character ( ), which indicates an
unlimited upper bound.
i specifies a singleton range that contains integer i, which is an integer literal.
* specifies the entire nonnegative integer range: 0. 1. 2. 3.. ..
0 . ·* 0 or more
1. · * 1 or more
2 .. 5 2 to 5
2, 5, 7 2, 5, and 7
1, 3, 5. ·* I, 3, and 5 or more
In Figure 2.5, the enroll a ociation i man -to-man ; that i a tudent may enroll
in any number of course . and a ourse ma have any number of tudent · enrolled
in it. The reach association i one-to-man ; that i ·. ea h ourse has onl one faculty
member to teach it, but a fa ult member ma tench an number of course . The
adviser-advisee a ·ociation L al o one--to-man ; that i , ea b . tudenl ha. one advi er,
but an advi er may ha e any number of ad i ee ·.
The graphical notation of an a iation ma al o indi ate the navigation of
the a o iation. If there i, a dire t or indirect refere nee from cl Cl to clas C2,
then it is navigabl from Cl to C2. n as , iation ma b nn igable in one or both
dire tions. By default, an a. s iation is a · ·urned to be navigable in both direction .
If nn a o iation is only navigable in one dire tion, it mu t be explicitly hown with
Another Random Scribd Document
with Unrelated Content
sing pun shen.” The pronunciation of the province of Szechuen is a
little heavier, viz: “Jen dze tsou, sin pen chan.” Now the boys of New
China are concluding that “Man in the beginning was essentially
misinformed!”
That the Chinese can become linguists has seldom been more
uniquely illustrated than in the following experience related by Prince
Henri d’Orleans. He was about to travel through the territories of the
aboriginal Lolo tribes of Yunnan province. The difficulty was to find
an interpreter. The general interpreter who only knew the Mandarin
pronunciation of the north, or the Cantonese pronunciation of the
south, would not do. The prince found at the Mission d’Etrangeres at
Tali, in remote Yunnan, an interpreter who knew the Lolo dialects,
and though he could not converse with the prince in French or
English, he could converse fairly well in Latin, and they got along
splendidly. It appears that the Catholic fathers had taught the
convert from the Latin Fathers, Jerome, Chrysostom, etc!
Eager as the Chinese are to learn from text-books, they more
eagerly cry for exhibits which appeal to the eye, and the
establishment of museums, heretofore neglected, except in the few
universities already mentioned, should be undertaken. Take one
week’s records at the Hongkong Museum, for instance. Four hundred
and sixteen non-Chinese and 163 Chinese used the library, but 193
non-Chinese and 3,100 Chinese studied in the museum. The
resourceful Canadian government sent a traveling exhibit through
China. It is what the Chinese call for. We shall yet see floating and
wheeled museums, in parvo, throughout the empire, as educational
bodies and merchants appreciate this as the quickest way to
approach the Chinese mind.
When the revolution of 1911 had developed strength, the
Chinese government found itself unable to remit to the thousands of
students who were studying in foreign countries. The American and
British universities, without exception, nobly offered to aid any
needy Chinese student. The move was brilliant and humane, and will
be bread scattered upon returning waters of appreciation some day.
The new representative assemblies have necessitated the
introduction of shorthand in China. The Tsze Chen Yuan (National
Assembly) in session at Peking as early as August, 1911, ordered
night classes to be opened for learning the art, so that the civil
service clerks might attend. I know that missionaries, helpless in
committing to paper accurately the sounds of the scores of Lolo,
Miaotsze, and other dialects in Yunnan, Szechuen and Kweichou
provinces (where aborigines abound) have had recourse effectually
to phonography. If the brilliant Dickens, John Hay, the American
secretary of state, who founded the policy of “non-partition of
China,” and many others, were phonographers, why might a
missionary not be one also!
Some of the educational proverbs of the Chinese are the
following:
“A lion breeds lions, and a brave father has brave sons.”
“Learn easy, forget easy; learn hard, forget hard.”
“Life is a river; if you are not going forward on it, you are falling
behind.”
“Youth jumps and slips; age picks its steps and crosses safely.”
“Measure words by the height of the brain, not the height of the
body.”
“A loose rein for a good head; a tight rein for a loose heart.”
“Faces are alike, but minds are myriad.”
“It takes longer to determine than to do.”
“Fate doesn’t plan the lot of a fool.”
“The mind chisels the face.”
“It isn’t far at the turn of two roads, but they end far apart.”
“With weeds, and with learning, get at the root.”
“Nothing that is human is alien to a good man’s interest.”
“He who has no ambition is like an ax without edge.”
“Moments are more precious than jewels, for the first can not be
recovered if lost; the second may be found.”
“A right beginning makes a proper ending.”
“A tight mouth keeps back much mischief.”
“Heaven never put a bar against resource.”
“When you know yourself thoroughly, you know everyone else.”
“Prejudice is the thief of persuasion.”
“Two things strangle, the tongue and the cord.”
“Be as cross to yourself as you are to others; be as sweet to
others as you are to yourself.”
“Never too great to learn.”
“The last step must be as steady as the first in climbing a hill.”
“The downy chin goes over it; the bristly chin goes round it; or,
the young head for the long jump, and the old head for the long
thought.”
“Good gives the tangible, evil but the shadows.”
“If you insist on every one being like you, look nowhere but in
your mirror.”
XIX
He also wrote:
“The waves of the Yangtze that pass to the sea,
Nevermore shall return to me;
So, friend of my soul, ’tis with me and with thee.”
Tai Chen, a poet, speaking for the Emperor Ming Huang, who is
pursued to Mount Omi, in Szechuen, by the rebel, An Lu Shen,
writes: “The star of empire pales before the morning beams of
conquering foes.” Some of his lyrics show pretty conceits like: “The
pansies are faces of loves that have died.” His Ruined Home reads
like parts of Solomon’s wisdom.
Tai Chen was preceded by the most famous poet of China, Li Po
(A. D. 702). He was born in Szechuen province. His patron was the
Emperor Ming Huang, then a wanderer, as we have stated. A
Browning-like poet of the world, he talks of the Tang emperors of
Nanking, patrons of sculptors, “calling down the dreams of the gods
and imprisoning them in stone.” In an ode to Nanking, he tells about:
“a woman asleep by a loom, and a beautiful dream guiding her
fingers along a glorious pattern that is known only to the gods.” He
believes in the high mission of the poet, for he sings of “the fadeless
lines of fire, running back to the births of immortal poets, who now
walk amidst the stars.” Like others of the Chinese, and many of the
new race of American poets, he has a strong sympathy with trade
unions. He addressed an ode To the Golden Presence of Guild
Brothers. He sings mightily of war in a song To my Fatherland, and
then lapses thus into a sadder note when he reflects upon whom the
sorrows of war come: “The pensive washwoman sends her heart to
the Tartar war in far Kansu province to find her conscript soldier
husband who suffers in the snows.”
Kao Shih, a contemporary poet, was a tremendous believer in the
personal soul. He wrote striking verse because of his love of the
occult, and his tendency to give to natural phenomena dramatic
personalities.
Ou Yang Hsiu, of the following dynasty, the Sung, 1007 A. D.,
himself a governor, and historian of the Tang dynasty, wrote a
famous “Autumn” poem, which is truly a march of Elizabethan
metaphors. He showed, too, a cynicism which was like the
Elizabethan:
“Fame, after all, is such a little thing!
Behold the fox and weasel’s young now play
Where lie the ashes of the great Man-Ching.”
MIAO
ABORIGINE CHINESE
1 Ah Ee
2 Ow Erh
3 Tsz San
4 Peu Su
5 Peh Wu
6 Glow Liu
7 Ya Pah
8 Chow Chiu
MEAT
Beef sirloin, Mei Lung Pa, 10 cents a pound.
Beef steak, Ngan Yuk Pa, 10 cents a pound.
Mutton chop, Yeung Pai Kwat, 12 cents a pound.
Pork chops, Chi Pai Kwat, 10 cents a pound.
Chicken, Chu Yau, 8 cents a pound.
Duck, Ap, 15 cents a pound.
Doves, Pan Kau, 7 cents each.
Geese, Ngoi, 13 cents a pound.
Turkeys, cock, Phor Kai Kung, 20 cents a pound.
FISH
Barbel, Ka Yu, 5 cents a pound.
Carp, Li Yu, 9 cents a pound.
Cod, Mun, 7 cents a pound.
Crabs, Hai, 9 cents a pound.
Cuttlefish, Muk, 6 cents a pound.
Eels, Conger, Hai Mann, 7 cents a pound.
Frogs, Tien Kai, 20 cents a pound.
Garoupa, Sek Pan, 28 cents a pound.
Halibut, Cheung Kwan Kup, 12 cents a pound.
Lobster, Lung Ha, 18 cents a pound.
Mackerel, Chi, 16 cents a pound.
Mullet, Chai, 10 cents a pound.
Parrotfish, Kai Kung, 8 cents a pound.
Pomfret, white, Pak Chong, 13 cents a pound.
Salmon, Ma Yau Yu, 16 cents a pound.
Shrimps, Ha, 12 cents a pound.
Soles, Tat Sa, 12 cents a pound.
South China is rich in fish, and I could quote scores more.
FRUIT
Almonds, Hung Yan, 9 cents a pound.
Apples, Chifu, Tin Chun Ping Khor, 7 cents a pound.
Bananas, fragrant Canton, San Shing Heung Chiu, 1½ cents a
pound.
Carambola, Yeung Tuo, 4 cents a pound.
Cocoanuts, Yeh Tsz, 5 cents each.
Lemons, Ning Moong, 4 cents a pound.
Lichees, Lai Chi, 5 cents a pound (called “Chinese nuts”).
Lily roots, Lin Ngan, 3 cents a pound.
Limes from Saigon, Sai Kung Ning Moong, 3 cents a pound.
Pears, Canton, Sa Li, 4 cents a pound.
Peanuts, Fa Sang, 5 cents a pound.
Persimmons, Hung Chie, 10 cents a pound.
Pineapples, Sheung Poon Ti Pau Lau, 5 cents each.
Plantains, Tai Chen, 1 cent each.
Plums, Swatow, Hung Lai, 5 cents a pound.
Pumelo, Siam, Chim Lo Yau (grapefruit), 5 cents each.
Walnuts, Hop Tuo, 6 cents a pound.
Watermelon, Sai Kwa, 1½ cents a pound.
VEGETABLES
Beans, sprouted, Ah Choi, 2 cents a pound.
Beets, Hung Choi, 1 cent each.
Brinjal, Ching Yuen, 2 cents a pound.
Cabbage, Kai Choy, 2 cents a pound.
Carrots, Kam Shun, 3 cents a pound.
Chilies, Red Hung Fa, 3 cents a pound.
Cucumbers, Ching Kwa, 1 cent each.
Garlic, Suen Tau, 3 cents a pound.
Ginger, young, Sun Tsz Keung, 3 cents a pound.
Corn, Suk Mai, 2 cents each.
Lettuce, Yeung San Choi, ½ cent each.
Onions, Sang Chung, 2 cents a pound.
Papaw, Tai Man, 5 cents each.
Potato, sweet, Fan Shu, 1½ cents a pound.
Spinach, Yin Choi, 2 cents a pound.
Tomatoes, Kan Ker, 3 cents a pound.
Vegetable marrow, Chit Kwa, 1 cent a pound.
Water cress, Sai Yeung Choi, 5 cents a pound.
Race meet at the Jockey Club, Wong Nei Chong Valley, Hongkong.
The cosmopolitan crowd: Hindus, Portuguese, Britons,
Americans, Japanese, Chinese, Parsees, etc. Note the famous
mat-shed for the “Hoi Polloi” in the background. These immense
structures are erected overnight, with matting and bamboo.
Copyright, 1913, The Bobbs-Merrill Company.
Many have asked what was the organization of the crown colony
of Hongkong Island, where 3,000 white troops, a navy, 2,000 Indian
troops, and 500 British, Indian and Chinese police guard and rule
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com