OOMD Module 3 Reference
OOMD Module 3 Reference
Process Overview
A software development process provides a basis for the organized production of software,
using a collection of predefined techniques and notations. The process in this book starts
with formulation of the problem, then continues through analysis, design, and implementa-
tion. The presentation of the stages is linear, but the actual process is seldom linear.
167
168 Chapter 10 / Process Overview
The entire process is seamless. You continually elaborate and optimize models as your focus
shifts from analysis to design to implementation. Throughout development the same con-
cepts and notation apply; the only difference is the shift in perspective from the initial em-
phasis on business needs to the later emphasis on computer resources.
An OO approach moves much of the software development effort up to analysis and de-
sign. It is sometimes disconcerting to spend more time during analysis and design, but this
extra effort is more than compensated by faster and simpler implementation. Because the re-
sulting design is cleaner and more adaptable, future changes are much easier.
Part 2 covers the first four topics and Part 3 covers implementation. In this book we em-
phasize development and only briefly consider testing, training, deployment, and mainte-
nance. These last four topics are important, but are not the focus of this book.
10.1.2 Analysis
Analysis focuses on creation of models. Analysts capture and scrutinize requirements by
constructing models. They specify what must be done, not how it should be done. Analysis
is a difficult task in its own right, and developers must fully understand the problem before
addressing the additional complexities of design. Sound models are a prerequisite for an ex-
tensible, efficient, reliable, and correct application. No amount of implementation patches
can repair an incoherent application and compensate for a lack of forethought.
During analysis, developers consider the available sources of information (documents,
business interviews, related applications) and resolve ambiguities. Often business experts are
not sure of the precise requirements and must refine them in tandem with software develop-
ment. Modeling quickens the convergence between developers and business experts, because
it is much faster to work with multiple iterations of models than with multiple implementa-
tions of code. Models highlight omissions and inconsistencies so that they can be resolved.
As developers elaborate and refine a model, it gradually becomes coherent.
There are two substages of analysis: domain analysis and application analysis. Domain
analysis focuses on real-world things whose semantics the application captures. For exam-
ple, an airplane flight is a real-world object that a flight reservation system must represent.
Domain objects exist independently of any application and are meaningful to business ex-
perts. You find them during domain analysis or by prior knowledge. Domain objects carry
information about real-world objects and are generally passive—domain analysis emphasiz-
es concepts and relationships, with much of the functionality being implicit in the class mod-
el. The job of constructing a domain model is mainly to decide which information to capture
and how to represent it.
Domain analysis is then followed by application analysis that addresses the computer
aspects of the application that are visible to users. For example, a flight reservation screen is
10.1 Development Stages 169
part of a flight reservation system. Application objects do not exist in the problem domain
and are meaningful only in the context of an application. Application objects, however, are
not merely internal design decisions, because the users see them and must agree with them.
The application model does not prescribe the implementation of the application. It describes
how the application appears from the outside—the black-box view of it. You cannot find ap-
plication classes with domain analysis, but you can often reuse them from previous applica-
tions. Otherwise, you must devise application objects during analysis as you think about
interfaces with other systems and how your application interacts with users.
10.1.5 Implementation
Implementation is the stage for writing the actual code. Developers map design elements to
programming language and database code. Often, tools can generate some of the code from
the design model.
10.1.6 Testing
After implementation, the system is complete, but it must be carefully tested before being
commissioned for actual use. The ideas that inspired the original project should have been
nurtured through the previous stages by the use of models. Testers once again revisit the orig-
inal business requirements and verify that the system delivers the proper functionality. Test-
ing can also uncover accidental errors (bugs) that have been introduced. If an application
runs on multiple hardware and operating system platforms, it should be tested on all of them.
170 Chapter 10 / Process Overview
Developers should check a program at several levels. Unit tests exercise small portions
of code, such as methods or possibly entire classes. Unit tests discover local problems and
often require that extra instrumentation be built into the code. System tests exercise a major
subsystem or the entire application. In contrast to unit tests, system tests can discover broad
failures to meet specifications. Both unit and system tests are necessary. Testing should not
wait until the entire application is coded. It must be planned from the beginning, and many
tests can be performed during implementation.
10.1.7 Training
An organization must train users so that they can fully benefit from an application. Training
accelerates users on the software learning curve. A separate team should prepare user docu-
mentation in parallel to the development effort. Quality control can then check the software
against the user documentation to ensure that the software meets its original goals.
10.1.8 Deployment
The eventual system must work in the field, on various platforms and in various configura-
tions. Unexpected interactions can occur when a system is deployed in a customer environ-
ment. Developers must tune the system under various loads and write scripts and install
procedures. Some customers will require software customizations. Staff must also localize
the product to different spoken languages and locales. The result is a usable product release.
10.1.9 Maintenance
Once development is complete and a system has been deployed, it must be maintained for con-
tinued success. There are several kinds of maintenance. Bugs that remain in the original system
will gradually appear during use and must be fixed. A successful application will also lead to
enhancement requests and a long-lived application will occasionally have to be restructured.
Models ease maintenance and transitions across staff changes. A model expresses the
business intent for an application that has been driven into the programming code, user in-
terface, and database structure.
lowed by implementation, testing, and deployment. Each stage is completed in its entirety
before the next stage is begun.
The waterfall approach is suitable for well-understood applications with predictable
outputs from analysis and design, but such applications seldom occur. Too many organiza-
tions attempt to follow a waterfall when requirements are fluid. This leads to the familiar sit-
uation where developers complain about changing requirements, and the business complains
about inflexible software development. A waterfall approach also does not deliver a useful
system until completion. This makes it difficult to assess progress and correct a project that
has gone awry.
Bibliographic Notes
The class design stage is renamed from object design in the first edition of this book.
Exercises
10.1 (2) It seems there is never enough time to do a job right the first time, but there is always time
to do it over. Discuss how the approach presented in this chapter overcomes this tendency of
human behavior. What kinds of errors do you make if you rush into the implementation phase
of a software project? Compare the effort required to prevent errors with that needed to detect
and correct them.
10.2 (4) This book explains how to use OO techniques to implement programs and databases. Dis-
cuss how OO techniques could be applied in other areas, such as language design, knowledge
representation, and hardware design.
11
System Conception
System conception deals with the genesis of an application. Initially some person, who un-
derstands both business needs and technology, thinks of an idea for an application. Develop-
ers must then explore the idea to understand the needs and devise possible solutions. The
purpose of system conception is to defer details and understand the big picture—what need
does the proposed system meet, can it be developed at a reasonable cost, and will the demand
for the result justify the cost of building it?
This chapter introduces the automated teller machine (ATM) case study that threads
throughout the remainder of the book.
173
174 Chapter 11 / System Conception
■ When is it needed? Two aspects of time are important. The first is the feasible time, the
time in which the system can be developed within the constraints of cost and available
resources. The other is the required time, when the system is needed to meet business
goals. You must make sure that the timing expectations driven by technical feasibility
are consistent with the timing the business requires. If there is a disconnect, you must
initiate a dialogue between technologists and business experts to reach a solution.
■ Why is it needed? You may need to prepare a business case for the new system if some-
one has not already done so. The business case contains the financial justification for
the new system, including the cost, tangible benefits, intangible benefits, risk, and alter-
natives. You must be sure that you clearly understand the motivation for the new sys-
tem. The business case will give you insight into what stakeholders expect, roughly in-
dicate the scope, and may even provide information for seeding your models. For a com-
mercial product, you should estimate the number of units that can be sold and determine
a reasonable selling price; the revenue must cover costs and a profit.
■ How will it work? You should brainstorm about the feasibility of the problem. For large
systems you should consider the merits of different architectures. The purpose of this
speculation is not to choose a solution, but to increase confidence that the problem can
be solved reasonably. You might need some prototyping and experimentation.
Develop software so that customers can access a bank’s computers and carry out their own
financial transactions without the mediation of a bank employee.
■ Who is the application for? A number of companies provide ATM products. Conse-
quently, only a vendor or a large financial company could possibly justify the cost and
effort of building ATM software.
A vendor would be competing for customers in an established market. A large ven-
dor could certainly enter such a market, but might find it advantageous to partner with
or acquire an existing supplier. A small vendor would need some special feature to dif-
ferentiate itself from the crowd and attract attention.
It is unlikely that a financial company could justify developing ATM software just
for its own use, because it would probably be more expensive than purchasing a product.
If a financial company wanted special features, it could partner with a vendor. Or it
might decide to create a separate organization that would build the software, sell it to
the sponsoring company, and then market it to others.
176 Chapter 11 / System Conception
For the ATM case study, we will assume that we are a vendor building the software.
We will assume that we are developing an ordinary product, since deep complexities of
the ATM problem domain are beyond the scope of this book.
■ What problems will it solve? The ATM software is intended to serve both the bank and
the customer. For the bank, ATM software increases automation and reduces manual
handling of routine paperwork. For the customer, the ATM is ubiquitous and always
available, handling routine transactions whenever and wherever the customer desires.
ATM software must be easy to use and convenient so that customers will use it in pref-
erence to bank tellers. It must be reliable and secure since it will be handling money.
■ Where will it be used? ATM software has become essential to financial institutions.
Customers take it for granted that a bank will have an ATM machine. ATM machines
are available at many stores, sporting events, and other locations throughout the world.
■ When is it needed? Any software development effort is a financial proposition. The in-
vestment in development ultimately leads to a revenue stream. From an economic per-
spective, it is desirable to minimize the investment, maximize the revenue, and realize
revenue as soon as possible. Thoughtful modeling and OO techniques are conducive to
this goal.
■ Why is it needed? There are many reasons why a vendor might decide to build a soft-
ware product. If other companies are making money with similar products, there is an
economic incentive to participate. A novel product could outflank competitors and lead
to premium pricing. Businesses commission internal efforts for technology that is diffi-
cult to buy and critical to them. We have no real motivation to develop ATM software,
other than to demonstrate the techniques in this book.
■ How will it work? We will adopt a three-tier architecture to separate the user interface
from programming logic, and programming logic from the database. In reality, the ar-
chitecture is n-tier, because there can be any number of intermediate programming lev-
els communicating with each other. We will discuss architecture further in the System
Design chapter.
what kinds of brake pads are on the wheels. Implementation deals with the ultimate realiza-
tion in programming code.
Frequently customers mix true requirements with design decisions. Usually this is a bad
idea. If you separate requirements from design decisions, you preserve the freedom to
change a design. Typically there are many possible ways to design a system, and you should
defer a solution until you fully understand a problem.
A system concept document may include an example implementation. The purpose of
the example is to show how the system could be implemented using current technology at a
reasonable cost. It is a “proof of existence” statement. However, make it clear that the sample
implementation could be done differently in the final system. The sample implementation is
merely proposed as a possibility.
For example, when the Apollo program to put a man on the moon in the 1960s was first
proposed, the plan was to place a rocket in earth orbit, then launch a landing vehicle directly
to the moon’s surface. In the final successful program, the rocket was launched directly into
a lunar orbit, from which the lander was launched to the moon’s surface. It was not a bad thing
to make the first proposal, however, as this gave confidence that there was a feasible approach.
As Figure 11.2 shows, the problem statement should state what is to be done and not
how it is to be implemented. It should be a statement of needs, not a proposal for a system
architecture. The requestor should avoid describing system internals, as this restricts devel-
opment flexibility. Performance specifications and protocols for interaction with external
systems are legitimate requirements. Software engineering standards, such as modular con-
struction, design for testability, and provision for future extensions, are also proper.
Figure 11.2 Kinds of requirements. Do not make early design and implementation
decisions or you will compromise development.
A problem statement may have more or less detail. A requirement for a conventional
product, such as a payroll program or a billing system, may have considerable detail. A re-
quirement for a research effort in a new area may lack details, but presumably the research
has some objective that should be clearly stated.
Most problem statements are ambiguous, incomplete, or even inconsistent. Some re-
quirements are just plain wrong. Some requirements, although precisely stated, have un-
pleasant consequences on the system behavior or impose unreasonable implementation
costs. Some requirements do not work out as well as the requestor thought. The problem
178 Chapter 11 / System Conception
statement is just a starting point for understanding the problem, not an immutable document.
The purpose of the subsequent analysis (next chapter) is to fully understand the problem and
its implications. There is no reason to expect that a problem statement prepared without a
full analysis will be correct.
Cashier
Station
ATM Account
Bank
Computer
Account
ATM Central
Computer
Account
Bank
Computer
ATM Account
Figure 11.3 ATM network. The ATM case study threads throughout the
remainder of this book.
Design the software to support a computerized banking network including both human cash-
iers and automatic teller machines (ATMs) to be shared by a consortium of banks. Each bank
provides its own computer to maintain its own accounts and process transactions against
them. Cashier stations are owned by individual banks and communicate directly with their
own bank’s computers. Human cashiers enter account and transaction data.
Automatic teller machines communicate with a central computer that clears transac-
tions with the appropriate banks. An automatic teller machine accepts a cash card, interacts
with the user, communicates with the central system to carry out the transaction, dispenses
cash, and prints receipts. The system requires appropriate recordkeeping and security provi-
sions. The system must handle concurrent accesses to the same account correctly.
The banks will provide their own software for their own computers; you are to design
the software for the ATMs and the network. The cost of the shared system will be appor-
tioned to the banks according to the number of customers with cash cards.
necessary to evaluate the feasibility of the system, the difficulty and risk of developing it, the
demand for the system, and the cost-benefit ratio. This process should consider the view-
points of all the stakeholders of the system and should make the trade-offs necessary to pro-
vide a good chance of success, not just technical success, but also business success. This
process usually results in some adjustments to the original idea. When the system conception
stage is complete, write a problem statement that serves as the starting point for analysis. The
problem statement need not be complete, and it will change during development, but the
writing of the statement helps to focus the attention of the project.
Exercises
11.1 (3) Consider a new antilock braking system for crash avoidance in an automobile. Elaborate the
following high-level questions and explain your answers.
a. Who is the application for? Who are the stakeholders? Estimate how many persons in your
country are potential customers.
b. Identify three features that should be included and three features that should be omitted.
c. Identify three systems with which it must work.
d. What are two of the largest risks?
11.2 (3) Repeat Exercise 11.1 for software that supports Internet selling of books.
11.3 (3) Repeat Exercise 11.1 for software that supports the remodeling of kitchens.
11.4 (3) Repeat Exercise 11.1 for an online auction system.
11.5 (4) Prepare a problem statement, similar to that for the ATM system, for each of the following
systems. You may limit the scope of the system, but be precise and avoid making implementa-
tion decisions. Use 75–150 words per specification.
a. bridge player
b. change-making machine
c. car cruise control
d. electronic typewriter
e. spelling checker
f. telephone answering machine
11.6 (3) Rephrase the following requirements to make them more precise. Remove any design deci-
sions posing as requirements:
a. A system to transfer data from one computer to another over a telecommunication line. The
system should transmit data reliably over noisy channels. Data must not be lost if the receiv-
180 Chapter 11 / System Conception
ing end cannot keep up or if the line drops out. Data should be transmitted in packets, using
a master–slave protocol in which the receiving end acknowledges or negatively acknowl-
edges all exchanges.
b. A system for automating the production of complex machined parts. The parts will be de-
signed using a three–dimensional drafting editor that is part of the system. The system will
produce tapes that can be used by numerical control (N/C) machines to actually produce the
parts.
c. A desktop publishing system, based on a what-you-see-is-what-you-get philosophy. The
system will support text and graphics. Graphics include lines, squares, rectangles, polygons,
circles, and ellipses. Internally, a circle is represented as a special case of an ellipse and a
square as a special case of a rectangle. The system should support interactive, graphical ed-
iting of documents.
d. A system for generating nonsense. The input is a sample document. The output is random
text that mimics the input text by imitating the frequencies of combinations of letters of the
input. The user specifies the order of the imitation and the length of the desired output. For
order N, every output sequence of N characters is found in the input and at approximately
the same frequency. As the order increases, the style of the output more closely matches the
input.
The system should generate its output with the following method: Select a position at ran-
dom in the document being imitated. Scan forward in the input text until a sequence of char-
acters is found that exactly matches the last N − 1 characters of the output. If you reach the
end of the input, continue scanning from the beginning. When a match is found, copy the
letter that follows the matched sequence from the input to the output. Repeat until the desired
amount of text is generated.
e. A system for distributing electronic mail over a network. Each user of the system should be
able to send mail from any computer account and receive mail on one designated account.
There should be provisions for answering or forwarding mail, as well as saving messages in
files or printing them. Also, users should be able to send messages to several other users at
once through distribution lists. Each computer on the net should hold any messages destined
for computers that are down.
12
Domain Analysis
Domain analysis, the next stage of development, is concerned with devising a precise, con-
cise, understandable, and correct model of the real world. Before building anything complex,
the builder must understand the requirements. Requirements can be stated in words, but these
are often imprecise and ambiguous. During analysis, we build models and begin to under-
stand the requirements deeply.
To build a domain model, you must interview business experts, examine requirements
statements, and scrutinize related artifacts. You must analyze the implications of the require-
ments and restate them rigorously. It is important to abstract important features first and de-
fer small details until later. The successful analysis model states what must be done, without
restricting how it is done, and avoids implementation decisions.
In this chapter you will learn how to take OO concepts and apply them to construct a
domain model. The model serves several purposes: It clarifies the requirements, it provides
a basis for agreement between the stakeholders and the developers, and it becomes the start-
ing point for design and implementation.
181
182 Chapter 12 / Domain Analysis
Users
Generate
Developers
requests System Conception
Managers
Problem
Statement
User interviews
Design
Figure 12.1 Overview of analysis. The problem statement should not be taken as im-
mutable, but rather as a basis for refining the requirements.
Perhaps even more important, the process of constructing a rigorous model of the problem
domain forces the developer to confront misunderstandings early in the development process
while they are still easy to correct.
The analysis model addresses the three aspects of objects: static structure of objects
(class model), interactions among objects (interaction model), and life-cycle histories of ob-
jects (state model). All three submodels are not equally important in every problem. Almost
all problems have useful class models derived from real-world entities. Problems concerning
reactive control and timing, such as user interfaces and process control, have important state
models. Problems containing significant computation as well as systems that interact with
other systems and different kinds of users have important interaction models.
Analysis is not a mechanical process. The exact representations involve judgment and
in many regards are a matter of art. Most problem statements lack essential information,
which must be obtained from the requestor or from the analyst’s knowledge of the real-world
problem domain. Also there is a choice in the level of abstraction for the model. The analyst
must communicate with the requestor to clarify ambiguities and misconceptions. The anal-
ysis models enable precise communication.
We have divided analysis into two substages. The first, domain analysis, is covered in
this chapter and focuses on understanding the real-world essence of a problem. The second,
application analysis, is covered in the next chapter and builds on the domain model—incor-
porating major application artifacts that are seen by users and must be approved by them.
12.2 Domain Class Model 183
As Figure 12.2 shows, begin by listing candidate classes found in the written description
of the problem. Don’t be too selective; write down every class that comes to mind. Classes
often correspond to nouns. For example, in the statement “a reservation system to sell tickets
to performances at various theaters” tentative classes would be Reservation, System, Ticket,
Performance, and Theater. Don’t operate blindly, however. The idea to is capture concepts;
not all nouns are concepts, and concepts are also expressed in other parts of speech.
Figure 12.2 Finding classes. You can find many classes by considering nouns.
Don’t worry much about inheritance or high-level classes; first get specific classes right
so that you don’t subconsciously suppress detail in an attempt to fit a preconceived struc-
ture. For example, if you are building a cataloging and checkout system for a library, iden-
tify different kinds of materials, such as books, magazines, newspapers, records, videos,
and so on. You can organize them into broad categories later, by looking for similarities and
differences.
ATM example. Examination of the concepts in the ATM problem statement from Chap-
ter 11 yields the tentative classes shown in Figure 12.3. Figure 12.4 shows additional classes
that do not appear directly in the statement but can be identified from our knowledge of the
problem domain.
Communications Transaction
Line Log
Bad Classes
Good Classes
Account ATM Bank Bank Cash Cashier
Computer Card
■ Redundant classes. If two classes express the same concept, you should keep the most
descriptive name. For example, although Customer might describe a person taking an
airline flight, Passenger is more descriptive. On the other hand, if the problem concerns
contracts for a charter airline, Customer is also an appropriate word, since a contract
might involve several passengers.
ATM example. Customer and User are redundant; we retain Customer because it
is more descriptive.
■ Irrelevant classes. If a class has little or nothing to do with the problem, eliminate it.
This involves judgment, because in another context the class could be important. For ex-
ample, in a theater ticket reservation system, the occupations of the ticket holders are
irrelevant, but the occupations of the theater personnel may be important.
ATM example. Apportioning Cost is outside the scope of the ATM software.
■ Vague classes. A class should be specific. Some tentative classes may have ill-defined
boundaries or be too broad in scope.
186 Chapter 12 / Domain Analysis
Account—a single account at a bank against which transactions can be applied. Ac-
counts may be of various types, such as checking or savings. A customer can hold
more than one account.
ATM—a station that allows customers to enter their own transactions using cash
cards as identification. The ATM interacts with the customer to gather transaction in-
formation, sends the transaction information to the central computer for validation
and processing, and dispenses cash to the user. We assume that an ATM need not
operate independently of the network.
Bank—a financial institution that holds accounts for customers and issues cash
cards authorizing access to accounts over the ATM network.
BankComputer—the computer owned by a bank that interfaces with the ATM net-
work and the bank’s own cashier stations. A bank may have its own internal comput-
ers to process accounts, but we are concerned only with the one that talks to the ATM
network.
CashCard—a card assigned to a bank customer that authorizes access of accounts
using an ATM machine. Each card contains a bank code and a card number. The
bank code uniquely identifies the bank within the consortium. The card number de-
termines the accounts that the card can access. A card does not necessarily access
all of a customer’s accounts. Each cash card is owned by a single customer, but mul-
tiple copies of it may exist, so the possibility of simultaneous use of the same card
from different machines must be considered.
Cashier—an employee of a bank who is authorized to enter transactions into cashier
stations and accept and dispense cash and checks to customers. Transactions,
cash, and checks handled by each cashier must be logged and properly accounted
for.
CashierStation—a station on which cashiers enter transactions for customers.
Cashiers dispense and accept cash and checks; the station prints receipts. The cash-
ier station communicates with the bank computer to validate and process the trans-
actions.
CentralComputer—a computer operated by the consortium that dispatches transac-
tions between the ATMs and the bank computers. The central computer validates
bank codes but does not process transactions directly.
Consortium—an organization of banks that commissions and operates the ATM net-
work. The network handles transactions only for banks in the consortium.
Customer—the holder of one or more accounts in a bank. A customer can consist of
one or more persons or corporations; the correspondence is not relevant to this prob-
lem. The same person holding an account at a different bank is considered a different
customer.
Transaction—a single integral request for operations on the accounts of a single
customer. We specified only that ATMs must dispense cash, but we should not pre-
clude the possibility of printing checks or accepting cash or checks. We may also
want to provide the flexibility to operate on accounts of different customers, although
it is not required yet.
Figure 12.6 Data dictionary for ATM classes. Prepare a data dictionary
for all modeling elements.
12.2 Domain Class Model 189
Verb phrases
Banking network includes cashier stations and ATMs
Consortium shares ATMs
Bank provides bank computer
Bank computer maintains accounts
Bank computer processes transaction against account
Bank owns cashier station
Cashier station communicates with bank computer
Cashier enters transaction for account
ATMs communicate with central computer about transaction
Central computer clears transaction with bank
ATM accepts cash card
ATM interacts with user
ATM dispenses cash
ATM prints receipts
System handles concurrent access
Banks provide software
Cost apportioned to banks
Implicit verb phrases
Consortium consists of banks
Bank holds account
Consortium owns central computer
System provides recordkeeping
System provides security
Customers have cash cards
Knowledge of problem domain
Cash card accesses accounts
Bank employs cashiers
ATM example. Bank computer processes transaction against account can be bro-
ken into Bank computer processes transaction and Transaction concerns account. Cash-
ier enters transaction for account can be broken similarly. ATMs communicate with cen-
tral computer about transaction is really the binary associations ATMs communicate
with central computer and Transaction entered on ATM.
■ Derived associations. Omit associations that can be defined in terms of other associa-
tions, because they are redundant. For example, GrandparentOf can be defined in terms
of a pair of ParentOf associations. Also omit associations defined by conditions on at-
tributes. For example, youngerThan expresses a condition on the birth dates of two per-
sons, not additional information.
As much as possible, classes, attributes, and associations in the class model should
represent independent information. Multiple paths between classes sometimes indicate
derived associations that are compositions of primitive associations. Consortium shares
ATMs is a composition of the associations Consortium owns central computer and Cen-
tral computer communicates with ATMs.
Be careful, because not all associations that form multiple paths between classes in-
dicate redundancy. Sometimes the existence of an association can be derived from two
or more primitive associations and the multiplicity can not. Keep the extra association
if the additional multiplicity constraint is important. For example, in Figure 12.8 a com-
pany employs many persons and owns many computers. Each employee is assigned
zero or more computers for the employee’s personal use; some computers are for public
use and are not assigned to anyone. The multiplicity of the AssignedTo association can-
not be deduced from the Employs and Owns associations.
Employs
Company Person
1 *
1 0..1
Although derived associations do not add information, they are useful in the real
world and in design. For example, kinship relationships such as Uncle, MotherInLaw,
and Cousin have names because they describe common relationships considered impor-
tant within our society. If they are especially important, you may show derived associ-
ations in class diagrams, but put a slash in front of their names to indicate their depen-
dent status and to distinguish them from fundamental associations.
Further specify the semantics of associations as follows:
■ Misnamed associations. Don’t say how or why a situation came about, say what it is.
Names are important to understanding and should be chosen with great care.
12.2 Domain Class Model 191
Consortium bankCode
0..1
Bank
1 * Account * 1
Customer
1
1
1 1 1 1 1 * 1
Employs
1 1
Communicates *
Central With Bank
Computer 1 Computer Cashier
*
1 1
1
CommunicatesWith EnteredBy
* * * *
Communicates Cashier EnteredOn Cashier
With Station 1 Transaction
*
*
EnteredOn Remote * *
ATM CashCard
1 Transaction
* * AuthorizedBy 1 *
Figure 12.9 Initial class diagram for ATM system
ing analysis, avoid attributes that are solely for implementation. Be sure to give each attribute
a meaningful name.
Normally, you should omit derived attributes. For example, age is derived from birth-
date and currentTime (which is a property of the environment). Do not express derived at-
tributes as operations, such as getAge, although you may eventually implement them that
way.
Also look for attributes on associations. Such an attribute is a property of the link be-
tween two objects, rather than being a property of an individual object. For example, the
many-to-many association between Stockholder and Company has an attribute of numberOf-
Shares.
multiplicity. For example, in an association between Person and Club the attribute mem-
bershipDate belongs to the association, because a person can belong to many clubs and
a club can have many members. Attributes are more subtle on one-to-many associations
because they could be attached to the “many” class without losing information. Resist
the urge to attach them to classes, as they would be invalid if multiplicity changed. At-
tributes are also subtle on one-to-one associations.
■ Internal values. If an attribute describes the internal state of an object that is invisible
outside the object, then eliminate it from the analysis.
■ Fine detail. Omit minor attributes that are unlikely to affect most operations.
■ Discordant attributes. An attribute that seems completely different from and unrelated
to all other attributes may indicate a class that should be split into two distinct classes.
A class should be simple and coherent. Mixing together distinct classes is one of the ma-
jor causes of troublesome models. Unfocused classes frequently result from premature
consideration of implementation decisions during analysis.
■ Boolean attributes. Reconsider all boolean attributes. Often you can broaden a boolean
attribute and restate it as an enumeration [Coad-95].
ATM example. We apply these criteria to obtain attributes for each class (Figure 12.10).
Some tentative attributes are actually qualifiers on associations. We consider several aspects
of the model.
■ BankCode and cardCode are present on the card. Their format is an implementation de-
tail, but we must add a new association Bank issues CashCard. CardCode is a qualifier
on this association; bankCode is the qualifier of Bank with respect to Consortium.
■ The computers do not have state relevant to this problem. Whether the machine is up or
down is a transient attribute that is part of implementation.
■ Avoid the temptation to omit Consortium, even though it is currently unique. It provides
the context for the bankCode qualifier and may be useful for future expansion.
Keep in mind that the ATM problem is just an example. Real applications, when fleshed out,
tend to have many more attributes per class than Figure 12.10 shows.
1 Issues
card
Code
account
Consortium bank
Code Bank Code 1 0..1 Account Customer
0..1
1
1 balance * 1
name
name employee
1 Code creditLimit address
station type
Code 1 1
1 Employs 1 1 *
1 1 0..1
Central Bank Cashier
bank 1 0..1
Computer Code Computer
name
station Communicates station 1
Code With Code
EnteredBy
1 1
CommunicatesWith
* *
0..1 0..1 CashierTransaction
Communicates CashierStation EnteredOn kind
With 1 * dateTime
amount
0..1
ATM EnteredOn RemoteTransaction
*
*
cashOnHand 1 * kind 1 CashCard
dateTime * *
amount AuthorizedBy password
0..1
■ Multiple inheritance. You can use multiple inheritance to increase sharing, but only if
necessary, because it increases both conceptual and implementation complexity.
■ Similar associations. When the same association name appears more than once with
substantially the same meaning, try to generalize the associated classes. Sometimes the
classes have nothing in common but the association, but more often you will uncover an
underlying generality that you have overlooked.
ATM example. Transaction is entered on both CashierStation and ATM; EntrySta-
tion generalizes CashierStation and ATM.
■ Adjusting the inheritance level. You must assign attributes and associations to specific
classes in the class hierarchy. Assign each one to the most general class for which it is
appropriate. You may need some adjustment to get everything right. Symmetry may
suggest additional attributes to distinguish among subclasses more clearly.
Figure 12.11 shows the ATM class model after adding inheritance.
EntryStation Transaction
1 EnteredOn * kind
dateTime
amount *
Transaction
EnteredOn * 1
dateTime
*
Update
1
amount
EntryStation Cashier Remote kind
Transaction Transaction
*
* *
EnteredBy
ATM CashierStation 1
AuthorizedBy
cashOnHand
0..1 0..1 Cashier
0..1
name
1
Employs Issues 0..1 Card
1 Authorization
1
station station CashCard password
1
Code Code * 1 limit
1 0..1 employee serialNumber
Consortium bank Bank Code * *
Code
name card 1
Code 1
account Customer
Code 1
Account * name
1 0..1
balance address
creditLimit *
type
1
For example, we encountered one application in which the developers had separate
classes for IndividualContributor, Supervisor, and Manager. IndividualContributors report
to Supervisors and Supervisors report to Managers. This model certainly is correct, but it
suffers from some problems. There is much commonality between the three classes—the
only difference is the reporting hierarchy. For example, they all have phone numbers and ad-
dresses. We could handle the commonality with a superclass, but that only makes the model
larger. An additional problem arose when we talked to the developers and they said they
wanted to add another class for the persons to whom managers reported.
Figure 12.13 shows the original model and an improved model that is more abstract. In-
stead of “hard coding” the management hierarchy in the model, we can “soft code” it with
an association between boss and worker. A person who has an employeeType of “individual-
Contributor” is a worker who reports to another person with an employeeType of “supervi-
sor.” Similarly, a person who is a supervisor reports to a person who is a manager. In the
improved model a worker has an optional boss, because the reporting hierarchy eventually
stops. The improved model is smaller and more flexible. An additional reporting level does
not change the model’s structure; it merely alters the data that is stored.
IndividualContributor
*
1
Supervisor
boss
* Person
1 0..1
employeeType *
Manager / reportingLevel
worker
Figure 12.13 Shifting the level of abstraction. Abstraction makes a model more
complex but can increase flexibility and reduce the number of classes.
One way that you can take advantage of abstraction is by thinking in terms of patterns.
Different kinds of patterns apply to the different development stages, but here we are inter-
ested in patterns for analysis. A pattern distills the knowledge of experts and provides a prov-
en solution to a general problem. For example, the right side of Figure 12.13 is a pattern for
modeling a management hierarchy. Whenever we encounter the need for a management hi-
erarchy, we immediately think in terms of the pattern and place it in our application model.
The use of tried and tested patterns gives us the confidence of a sound approach and boosts
our productivity in building models.
ATM example. We have already included some abstractions in the ATM model. We dis-
tinguished between a CashCard and a CardAuthorization. Furthermore, we included the no-
tion of transactions rather than trying to list each possible kind of interaction.
12.3 Domain State Model 201
First identify the domain classes with significant states and note the states of each class.
Then determine the events that take an object from one state to another. Given the states and
the events, you can build state diagrams for the affected objects. Finally, evaluate the state
diagrams to make sure they are complete and correct.
The following steps are performed in constructing a domain state model.
■ Identify domain classes with states. [12.3.1]
■ Find states. [12.3.2]
■ Find events. [12.3.3]
■ Build state diagrams. [12.3.4]
■ Evaluate state diagrams. [12.3.5]
Account
Closed
close account
withdraw excess funds
open account
Normal Overdrawn
deposit sufficient funds
administrative action
Suspended
repeated incorrect PIN
Figure 12.14 Domain state model. The domain state model documents important
classes that change state in the real world.
Use your knowledge of the domain to look for missing paths. Sometimes missing paths
indicate missing states. When a state model is complete, it should accurately represent the
life cycle of the class.
ATM example. Our state model for Account is simplistic but we are satisfied with it.
We would require substantial banking knowledge to construct a deeper model.
The final verified analysis model serves as the basis for system architecture, design, and
implementation. You should revise the original problem statement to incorporate corrections
and understanding discovered during analysis.
Bibliographic Notes
Abbott explains how to use nouns and verbs in the problem statement to seed thinking about
an application [Abbott-83]. [Coad-95] is a good book with some examples of analysis pat-
terns.
References 207
References
[Abbott-83] Russell J. Abbott. Program Design by Informal English Descriptions. Communications of
the ACM 26, 11 (November 1983), 882–894.
[Coad-95] Peter Coad, David North, and Mark Mayfield. Object Models: Strategies, Patterns, and Ap-
plications. Upper Saddle River, NJ: Yourdon Press, 1995.
Exercises
12.1 (3) For each of the following systems, identify the relative importance of the three aspects of
modeling: 1) class modeling, 2) state modeling, 3) interaction modeling. Explain your answers.
For example, for a compiler, the answer might be 3, 1, and 2. Interaction modeling is most im-
portant for a compiler because it is dominated by data transformation concerns.
a. bridge player
b. change-making machine
c. car cruise control
d. electronic typewriter
e. spelling checker
f. telephone answering machine
12.2 (7) Create a class diagram for each system from Exercise 11.6. Note that the requirements are
incomplete, so your class models will also be incomplete.
Exercises 12.3–12.8 are related. Do the exercises in sequence. The following are tentative specifica-
tions for a simple diagram editor that could be used as the core of a variety of applications.
The editor will be used interactively to create and modify drawings. A drawing contains several
sheets. Drawings are saved to and loaded from named ASCII files. Sheets contain boxes and links.
Each box may optionally contain a single line of text. Text is allowed only in boxes. The editor must
automatically adjust the size of a box to fit any enclosed text. The font size of the text is not adjustable.
Any pair of boxes on the same sheet may be linked by a series of alternating horizontal and vertical
lines. Figure E12.1 shows a simple, one sheet drawing.
The editor will be menu driven, with pop-up menus. A three-button mouse will be used for menu,
object, and link selections. The following are some operations the editor should provide: create sheet,
delete sheet, next sheet, previous sheet, create box, link boxes, enter text, group selection, cut selec-
tions, move selections, copy selections, paste, edit text, save drawing, and load drawing. Copy, cut,
208 Chapter 12 / Domain Analysis
+
x+y
y
and paste will work through a buffer. Copy will create a copy of selections from a sheet to the buffer.
Cut will remove selections to the buffer. Paste will copy the contents of the buffer to the sheet. Each
copy and cut operation overwrites the previous contents of the buffer. Pan and zoom will not be al-
lowed; sheets will have fixed size. When boxes are moved, enclosed text should move with them and
links should be stretched.
12.3 (3) The following is a list of candidate classes. Prepare a list of classes that should be eliminated
for any of the reasons given in this chapter. Give a reason for each elimination. If there is more
than one reason, give the main one.
character, line, x coordinate, y coordinate, link, position, length, width, collection, selection,
menu, mouse, button, computer, drawing, drawing file, sheet, pop-up, point, menu item, se-
lected object, selected line, selected box, selected text, file name, box, buffer, line segment
coordinate, connection, text, name, origin, scale factor, corner point, end point, graphics ob-
ject.
12.4 (3) Prepare a data dictionary for proper classes from the previous exercise.
12.5 (3) The following is a list of candidate associations and generalizations for the diagram editor.
Prepare a list of associations and generalizations that should be eliminated or renamed for any
of the reasons given in this chapter. Give a reason for each elimination or renaming. If there is
more than one reason, give the main one.
a box has text, a box has a position, a link logically associates two boxes, a box is moved, a
link has points, a link is defined by a sequence of points, a selection or a buffer or a sheet is
a collection, a character string has a location, a box has a character string, a character string
has characters, a line has length, a collection is composed of links and boxes, a link is delet-
ed, a line is moved, a line is a graphical object, a point is a graphical object, a line has two
points, a point has an x coordinate, a point has a y coordinate
12.6 Figure E12.2 is a partially completed class diagram for the diagram editor. Show how could it
be used for each of the following queries. Use a combination of the OCL (see Chapter 3) and
pseudocode to express your queries.
a. (2) Find all selected boxes and links.
b. (4) Given a box, determine all other boxes that are directly linked to it.
c. (8) Given a box, find all other boxes that are directly or indirectly linked to it.
d. (2) Given a box and a link, determine if the link involves the box.
e. (3) Given a box and a link, find the other box logically connected to the given box through
the other end of the link.
f. (4) Given two boxes, determine all links between them.
g. (6) Given a selection, determine which links are “bridging” links. If a selection does not in-
clude all boxes on a sheet, “bridging” links may result. A “bridging” link is a link that con-
Exercises 209
2 *
Text Box Collection Link
0..1 1 * 1 1 *
nects a box that has been selected to a box that has not. A link that connects two boxes that
are selected or two boxes that are not selected is not a “bridging” link. “Bridging” links re-
quire special handling during a cut or a move operation on a selection.
12.7 (6) Figure E12.3 is a variation of the class diagram in which the class Connection explicitly rep-
resents the connection of a link to a box. Redo the queries from the previous exercise using this
representation.
* Connection 2
1 1
Figure E12.3 Alternative partially completed class diagram for a diagram editor
12.8 (5) What classes require state diagrams? Describe some relevant states and events.
Exercises 12.9–12.13 are related. Do the exercises in sequence. These exercises concern a computer-
ized scoring system that you have volunteered to create for the benefit of a local children’s synchro-
nized swimming league. Teams get together for competitions called meets during which the children
perform in two types of events: figures and routines. Figure events, which are performed individually,
are particular water ballet maneuvers such as swimming on your back with one leg raised straight up.
Routines, which are performed by the entire team, are water ballets. Both figures and routines are
scored, but your system need only address figures.
Each child must provide his or her name, age, address, and team name to register prior to the meet.
To simplify scoring, each contestant is assigned a number.
During a meet, figure events are held simultaneously at several stations that are set up around a
swimming pool, usually one at each corner. There are volunteer judges and scorekeepers. Scorekeep-
ers tend to tire, so there is often turnover in their ranks. Several judges and scorekeepers are assigned
to each station during a meet. Over the course of a season each judge and scorekeeper may serve sev-
210 Chapter 12 / Domain Analysis
eral stations. For scoring consistency, each figure is held at exactly one station with the same judges.
A station may process several figure events in the course of a meet.
Contestants are organized into groups, with each group starting at a different station. When a child
is finished at one station, he or she proceeds to another station for another event. When everyone has
been processed at a station for a given event, the station switches to the next event assigned to it.
Each competitor gets one try at each event, called a trial. Just before a trial, the child’s number is
announced to the child and to the scorekeepers. Sometimes the children get out of order or the score-
keepers become confused and the station stops while the problem is fixed. Each judge indicates a raw
score for each observed trial by holding up numbered cards. The raw scores are read to the scorekeep-
ers, who record them and compute a net score for the trial. The highest and lowest raw scores are dis-
carded, and the average of the remaining scores is multiplied by a difficulty factor for the figure.
Individual and team prizes are awarded at the conclusion of a meet based on top individual and
team scores. There are several age categories, with separate prizes for each category. Individual prizes
are based on figures only. Team prizes are based on figures and routines.
Your system will be used to store all information needed for scheduling, registering, and scoring.
At the beginning of a season, all swimmers will be entered into the system and a season schedule will
be prepared, including deciding which figures will be judged at which meets. Prior to a meet, the sys-
tem will be used to process registrations. During a meet, it will record scores and determine winners.
12.9 (3) The following is a list of candidate classes for the scoring system. Prepare a list of classes
that should be eliminated for any of the reasons given in this chapter. Give a reason for each
elimination. If there is more than one reason, give the main one.
address, age, age category, average score, back, card, child, child’s name, competitor, com-
pute average, conclusion, contestant, corner, date, difficulty factor, event, figure, file of team
member data, group, individual, individual prize, judge, league, leg, list of scheduled meets,
meet, net score, number, person, pool, prize, register, registrant, raw score, routine, score,
scorekeeper, season, station, team, team prize, team name, trial, try, water ballet.
12.10 (3) Prepare a data dictionary for proper classes from the previous exercise.
12.11 (4) The following is a list of candidate associations and generalizations for the scoring system.
Prepare a list of associations and generalizations that should be eliminated or renamed for any
of the reasons given in this chapter. Give a reason for each elimination or renaming. If there is
more than one reason, give the main one.
a season consists of several meets, a competitor registers, a competitor is assigned a number,
a number is announced, competitors are split into groups, a meet consists of several events,
several stations are set up at a meet, several events are processed at a station, several judges
are assigned to a station, routines and figures are events, raw scores are read, highest score
is discarded, lowest score is discarded, figures are processed, a league consists of several
teams, a team consists of several competitors, a trial of a figure is made by a competitor, a
trial receives several scores from the judges, prizes are based on scores.
12.12 Figure E12.4 is a partially completed class diagram for the scoring system. The association be-
tween meet and event is not derived, because an event may be determined for a meet before a
station is assigned to it. Show how it could be used for each of the following queries. Use a com-
bination of the OCL (see Chapter 3) and pseudocode to express your queries.
a. (2) Find all the members of a given team.
b. (6) Find which figures were held more than once in a given season.
Exercises 211
c. (6) Find the net score of a competitor for a given figure at a given meet.
d. (6) Find the team average over all figures in a given season.
e. (6) Find the average score of a competitor over all figures in a given meet.
f. (6) Find the team average in a given figure at a given meet.
g. (4) Find the set of all individuals who competed in any events in a given season.
h. (7) Find the set of all individuals who competed in all of the events held in a given season.
i. (6) Find all the judges who judged a given figure in a given season.
j. (6) Find the judge who awarded the lowest score during a given event.
k. (6) Find the judge who awarded the lowest score for a given figure.
l. (7) Modify the diagram so that the competitors registered for an event can be determined.
12.13 (5) What classes require state diagrams? Describe some relevant states and events.
12.14 (7) Revise the diagrams in Figure E12.5, Figure E12.6, Figure E12.7, and Figure E12.8 to elim-
inate ternary associations. In some cases you will have to promote the association to a class.
Figure E12.5 is a relationship between Doctor, Patient, and DateTime that might be encoun-
tered in a system used by a clinic with several doctors on the staff. The combination of DateTime
+ Patient is unique as well as DateTime + Doctor.
Figure E12.6 is a relationship between Student, Professor, and University that might be used
to express the contacts between students attending and professors teaching at several universi-
ties. There is one link in the relationship for a student that takes one or more classes from a pro-
fessor at a university. The combination of Student + Professor + University is unique.
Figure E12.7 shows the relationship expressing the seating arrangement at a concert.
Concert + Seat is unique.
Figure E12.8 expresses the connectivity of a directed graph. Each edge of a directed graph
is connected in a specific order to exactly two vertices. More than one edge can be connected
between a given pair of vertices. The attribute Edge is unique for the relationship.
In each case, try to come as close as possible to the original intent and compare the merits of
the original and the revised models.
212 Chapter 12 / Domain Analysis
Doctor * * DateTime
*
Patient
Student
* * University
*
Professor
Seat * * Concert
*
Person
* toVertex
*
Edge Vertex
* fromVertex
12.15 (9) Figure E12.9 lists requirements for a document manager. We then prepared the initial model
in Figure E12.10. Note some flaws in the model.
Develop software for managing professional records of papers, books, journals, notes, and
computer files. The system must be able to record authors of published works in the appro-
priate order, name of work, date of publication, publisher, publisher city, an abstract, as well
as a comment. The software must be able to group published works into various categories
that are defined by the user to facilitate searching. The user must be able to assign a quality
indicator of the perceived value of each work.
Only some of the papers in each issue of a journal may be of interest. It would also be
helpful to be able to attach comments to sections or even individual pages of a work.
Publisher
publisherName 0..1
publisherCity * Document 1 0..1
sectionName Section
name comment
Author * {ordered} * date
name abstract pageNumber
qualityScore 1
DocumentCategory
* * comment
0..1
categoryName Page
comment
Exercises 12.16–12.19 are related. Do the exercises in sequence. The following are tentative specifi-
cations for scheduling software.
The scheduling software must support the following functions: arranges meetings, schedules ap-
pointments, plans tasks, and tracks holidays (including vacations).
The scheduler runs on a network that many users share. Each user may have a schedule. A schedule
contains multiple entries. Most entries belong to a single schedule; however, a meeting entry may ap-
pear in many schedules.
There are four kinds of entries: meetings, appointments, tasks, and holidays. Meetings and ap-
pointments both occur within a single day and have a start time and end time. In contrast, tasks and
holidays may extend over several days and just have a start date and end date. Any entry may be
repeated. Repeat information includes how often the entry should be repeated, when it starts, and
when it ends.
12.16 (3) The following is a list of candidate classes. Prepare a list of classes that should be eliminated
for any of the reasons given in this chapter. Give a reason for each elimination. If there is more
than one reason, give the main one.
214 Chapter 12 / Domain Analysis
scheduling software, function, meeting, appointment, task, holiday, vacation, scheduler, net-
work, user, schedule, entry, meeting entry, day, start time, end time, start date, end date, re-
peat information.
12.17 (3) Prepare a data dictionary for proper classes from the previous exercise.
12.18 (4) The following is a list of candidate associations and generalizations for the scoring system.
Prepare a list of associations and generalizations that should be eliminated or renamed for any
of the reasons given in this chapter. Give a reason for each elimination or renaming. If there is
more than one reason, give the main one.
■ scheduling software that supports the following functions
■ the scheduler runs on a network that many users share
■ user may have a schedule
■ a schedule contains multiple entries
■ entries pertain to a single schedule
■ a meeting entry may appear in many schedules
■ meetings and appointments both occur within a single day and have a start time and end time
■ tasks and holidays may extend over several days and just have a start date and end date.
12.19 (5) Construct a class model for the scheduling software.
Exercises 12.20–12.23 are related. Do the exercises in sequence. The following provides requirements
for meetings and extends the scheduling software from Exercises 12.16–12.19.
The scheduling software facilitates meetings. When a user (the chairperson) arranges a meeting,
the software places a meeting entry in the schedule of each attendee. The chairperson uses the sched-
uler to reserve a room for the meeting, to identify the attendees, and to find time on their schedules
when everyone is available. The chairperson can indicate whether the attendance for each attendee is
required or optional. The system tracks the acceptance status for each attendee—whether an attendee
has accepted or declined.
The scheduler manages meeting notices. When a meeting is set up, the scheduler sends invitations
to all attendees, who are able to view meeting information. Each invitee can accept or refuse as well
as possibly cancel later on. The system also manages notices in case the meeting is rescheduled or can-
celled.
12.20 (3) The following is a list of candidate classes. Prepare a list of classes that should be eliminated
for any of the reasons given in this chapter. Give a reason for each elimination. If there is more
than one reason, give the main one.
scheduling software, meeting, user, chairperson, software, meeting entry, schedule, attend-
ee, scheduler, room, time, everyone, attendance, acceptance status, meeting notice, invita-
tion, meeting information, invitee, notice.
12.21 (3) Prepare a data dictionary for proper classes from the previous exercise.
12.22 (4) The following is a list of candidate associations and generalizations. Prepare a list of asso-
ciations and generalizations that should be eliminated or renamed for any of the reasons given
in this chapter. Give a reason for each elimination or renaming. If there is more than one reason,
give the main one.
■ scheduling software facilitates meetings
Exercises 215