Prentice Object Oriented Software Engineering Using UML Patterns and Java 3rd 2012-1 2
Prentice Object Oriented Software Engineering Using UML Patterns and Java 3rd 2012-1 2
The work products associated with the ARENA system, along with a demonstration, are available
from http://wwwbruegge.in.tum.de/OOSE/WebHome.
1.8 Exercises
1-1 What is the purpose of modeling?
1-2 A programming language is a notation for representing algorithms and data structures.
List two advantages and two disadvantages of using a programming language as the
sole notation throughout the development process.
1-3 Consider a task you are not familiar with, such as designing a zero-emissions car. How
would you attack the problem?
1-4 What is meant by “knowledge acquisition is not sequential”? Provide a concrete
example of knowledge acquisition that illustrates this.
1-5 Hypothesize a rationale for the following design decisions:
26 Chapter 1 • Introduction to Software Engineering
1-6 Specify which of these statements are functional requirements and which are
nonfunctional requirements:
1-7 Specify which of these decisions were made during requirements or system design:
1-8 In the following description, explain when the term account is used as an application
domain concept and when as a solution domain concept:
“Assume you are developing an online system for managing bank accounts for
mobile customers. A major design issue is how to provide access to the accounts
when the customer cannot establish an online connection. One proposal is that
accounts are made available on the mobile computer, even if the server is not up. In
this case, the accounts show the amounts from the last connected session.”
1-10 A passenger aircraft is composed of several millions of parts and requires thousands of
persons to assemble. A four-lane highway bridge is another example of complexity.
The first version of Word for Windows, a word processor released by Microsoft in
1989, required 55 person-years, resulted into 249,000 lines of source code, and was
delivered 4 years late. Aircraft and highway bridges are usually delivered on time and
within budget, whereas software is often not. Discuss what are, in your opinion, the
differences between developing an aircraft, a bridge, and a word processor that would
cause this situation.
72 Chapter 2 • Modeling with UML
The OMG Unified Modeling Language Superstructure [OMG, 2009] is the official
specification of UML. It is continuously maintained by a revision task force that is responsible
for clarifying ambiguities, correcting errors, and resolving inconsistencies found by the UML
community.
2.6 Exercises
2-1 Consider an ATM system. Identify at least three different actors that interact with this
system.
2-2 Can the system under consideration be represented as an actor? Justify your answer.
2-3 What is the difference between a scenario and a use case? When do you use each
construct?
2-4 Draw a use case diagram for a ticket distributor for a train system. The system includes
two actors: a traveler who purchases different types of tickets, and a central computer
system that maintains a reference database for the tariff. Use cases should include
BuyOneWayTicket, BuyWeeklyCard, BuyMonthlyCard, and UpdateTariff. Also include
the following exceptional cases: TimeOut (i.e., traveler took too long to insert the right
amount), TransactionAborted (i.e., traveler selected the cancel button without
completing the transaction), DistributorOutOfChange, and DistributorOutOfPaper.
2-5 Write the flow of events and specify all fields for the use case UpdateTariff that you
drew in Exercise 2-4. Do not forget to specify any relationships.
2-6 Draw a class diagram representing a book defined by the following statement: “A book
is composed of a number of parts, which in turn are composed of a number of chapters.
Chapters are composed of sections.” Focus only on classes and relationships.
2-7 Add multiplicity to the class diagram you produced in Exercise 2-6.
2-8 Draw an object diagram representing the first part of this book (i.e., Part I, Getting
Started). Make sure that the object diagram you draw is consistent with the class
diagram of Exercise 2-6.
2-9 Extend the class diagram of Exercise 2-6 to include the following attributes:
• a book includes a publisher, publication date, and an ISBN
• a part includes a title and a number
• a chapter includes a title, a number, and an abstract
• a section includes a title and a number.
2-10 Consider the class diagram of Exercise 2-9. Note that the Part, Chapter, and Section
classes all include title and number attributes. Add an abstract class and an inheritance
relationship to factor out these two attributes into the abstract class.
2-11 Draw a class diagram representing the relationship between parents and children. Take
into account that a person can have both a parent and a child. Annotate associations
with roles and multiplicities.
Exercises 73
2-12 Draw a class diagram for bibliographic references. Use the references in Appendix C,
Bibliography, to test your class diagram. Your class diagram should be as detailed as
possible.
2-13 Draw a sequence diagram for the warehouseOnFire scenario of Figure 2-21. Include
the objects bob, alice, john, FRIEND, and instances of other classes you may need.
Draw only the first five message sends.
2-14 Draw a sequence diagram for the ReportIncident use case of Figure 2-14. Draw only
the first five message sends. Make sure it is consistent with the sequence diagram of
Exercise 2-13.
2-15 Consider the process of ordering a pizza over the phone. Draw an activity diagram
representing each step of the process, from the moment you pick up the phone to the
point where you start eating the pizza. Do not represent any exceptions. Include
activities that others need to perform.
2-16 Add exception handling to the activity diagram you developed in Exercise 2-15.
Consider at least three exceptions (e.g., delivery person wrote down wrong address,
delivery person brings wrong pizza, store out of anchovies).
2-17 Consider the software development activities which we described in Section 1.4 in
Chapter 1, Introduction to Software Engineering. Draw an activity diagram depicting
these activities, assuming they are executed strictly sequentially. Draw a second activity
diagram depicting the same activities occurring incrementally (i.e., one part of the
system is analyzed, designed, implemented, and tested completely before the next part
of the system is developed). Draw a third activity diagram depicting the same activities
occurring concurrently.
Exercises 115
3.7 Exercises
3-1 What is the difference between a role and a participant?
3-2 Can a role be shared between two or more participants? Why or why not?
3-3 What is the difference between a client and an end user?
3-4 To which roles would you assign the following tasks?
• Change a subsystem interface to accommodate a new requirement.
• Communicate the subsystem interface change to other teams.
• Change the documentation as a result of the interface change.
• Design a test suite to find defects introduced by the change.
• Ensure that the change is completed on schedule.
3-5 You are responsible for coordinating the development of a system for processing credit
applications for a bank. In what roles would the following project participants be able
to contribute most to the project?
• a bank employee responsible for processing credit applications
• the manager of the information technology group at the bank, who contracted the
system
• a freelancer who developed similar systems in the past
• a technical writer
• you.
3-6 Draw a UML activity diagram representing the meeting process described in
Section 3.4.1. Focus in particular on the work products generated before and after the
meeting, such as the agenda and the meeting minutes. Use swimlanes to represent
roles.
3-7 What is the difference between a work package and a work product? When is a work
package defined? When is a work product defined? Consider an assignment where two
students collaborate to plan and develop a system for sorting lists of names using two
different sort algorithms. The deliverables for the assignment are the source code, the
system documentation, and a manual for other developers explaining how new sorting
algorithms can be integrated into the code. Give examples of work packages and work
products in this project.
3-8 What is the difference between a cross-functional team and a subsystem team? Provide
examples and justify your choices.
3-9 As many critical communication events are planned (e.g., client reviews, project
reviews, peer reviews), why is there still a need for unplanned communication events
(e.g., request for clarification, request for change, issue resolution)?
3-10 Select at random a working day in your work week. Log all activities that qualify as
communication activities (e.g., taking to friends over coffee, obtaining information
116 Chapter 3 • Project Organization and Communication
software requirements specifications [IEEE Std. 830-1998]. The appendix of the standard
contains several sample outlines for the description of specific requirements.
The examples in this chapter followed a dialectic approach to requirements elicitation, a
process of discussion and negotiation among developers, the client, and the end users. This
approach works well when the client is the end user, or when the client has a sufficiently detailed
knowledge of the application domain. In large systems, such as an air traffic control system, no
single user or client has a complete perspective of the system. In these situations, the dialectic
approach breaks down, as much implicit knowledge about the users’ activities is not
encountered until too late. In the past decade, ethnography, a field method from anthropology,
has gained popularity in requirements engineering. Using this approach, analysts immerse
themselves in the world of users, observe their daily work, and participate in their meetings.
Analysts record their observations from a neutral point of view. The goal of such an approach is
to uncover implicit knowledge. The coherence method, reported in Social analysis in the
requirements engineering process: from ethnography to method [Viller & Sommerville, 1999],
provides a practical example of ethnography applied to requirements engineering.
Managing traceability beyond requirements is still a research topic, the reader is referred
to the specialized literature [Jarke, 1998].
Finally, Software Requirements & Specifications: A Lexicon of Practice, Principles and
Prejudices [Jackson, 1995] is a concise, incisive, and entertaining piece that provides many
insights into principles and methods of requirements engineering.
4.8 Exercises
4-1 Consider your watch as a system and set the time 2 minutes ahead. Write down each
interaction between you and your watch as a scenario. Record all interactions, includ-
ing any feedback the watch provides you.
4-2 Consider the scenario you wrote in Exercise 4-1. Identify the actor of the scenario.
Next, write the corresponding use case SetTime. Include all cases, and include setting
the time forward and backward, and setting hours, minutes, and seconds.
4-3 Assume the watch system you described in Exercises 4-1 and 4-2 also supports an
alarm feature. Describe setting the alarm time as a self-contained use case named
SetAlarmTime.
4-4 Examine the SetTime and SetAlarmTime use cases you wrote in Exercises 4-2 and 4-3.
Eliminate any redundancy by using an include relationship. Justify why an include
relationship is preferable to an extend relationship in this case.
4-5 Assume the FieldOfficer can invoke a Help feature when filling an
EmergencyReport. The HelpReportEmergency feature provides a detailed description
for each field and specifies which fields are required. Modify the ReportEmergency use
case (described in Figure 4-10) to include this help functionality. Which relationship
should you use to relate the ReportEmergency and HelpReportEmergency?
170 Chapter 4 • Requirements Elicitation
5.8 Exercises
5-1 Consider a file system with a graphical user interface, such as Macintosh’s Finder,
Microsoft’s Windows Explorer, or Linux’s KDE. The following objects were identified
from a use case describing how to copy a file from a floppy disk to a hard disk: File,
Icon, TrashCan, Folder, Disk, Pointer. Specify which are entity objects, which are
boundary objects, and which are control objects.
5-2 Assuming the same file system as before, consider a scenario consisting of selecting a
File on a floppy, dragging it to Folder and releasing the mouse. Identify and define at
least one control object associated with this scenario.
5-3 Arrange the objects listed in Exercises 5-1 and 5-2 horizontally on a sequence diagram,
the boundary objects to the left, then the control object you identified, and finally, the
entity objects. Draw the sequence of interactions resulting from dropping the file into a
folder. For now, ignore the exceptional cases.
5-4 Examining the sequence diagram you produced in Exercise 5-3, identify the
associations between these objects.
5-5 Identify the attributes of each object that are relevant to this scenario (copying a file
from a floppy disk to a hard disk). Also consider the exception cases “There is already
a file with that name in the folder” and “There is no more space on disk.”
5-6 Consider the object model in Figure 5-32 (adapted from [Jackson, 1995]):
Year
1
*
Month
1
*
Week
1
*
Day
Figure 5-32 A naive model of the Gregorian calendar (UML class diagram).
Given your knowledge of the Gregorian calendar, list all the problems with this model.
Modify it to correct each of them.
5-7 Consider the object model of Figure 5-32. Using association multiplicity only, can you
modify the model such that a developer unfamiliar with the Gregorian calendar could
deduce the number of days in each month? Identify additional classes if necessary.
220 Chapter 5 • Analysis
5-8 Consider a traffic light system at a four-way crossroads (two roads intersecting at right
angles). Assume the simplest algorithm for cycling through the lights (e.g., all traffic on
one road is allowed to go through the crossroad, while the other traffic is stopped).
Identify the states of this system and draw a state machine describing them. Remember
that each individual traffic light has three states (green, yellow, and red).
5-9 From the sequence diagram Figure 2-34, draw the corresponding class diagram. Hint:
Start with the participating objects in the sequence diagram.
5-10 Consider the addition of a nonfunctional requirement stipulating that the effort needed
by Advertisers to obtain exclusive sponsorships should be minimized. Change the
AnnounceTournament (Figure 5-23) and the ManageAdvertisements use case (solution
of Exercise 4-12) so that the Advertiser can specify preferences in her profile so that
exclusive sponsorships can be decided automatically by the system.
5-11 Identify and write definitions for any additional entity, boundary, and control objects
participating in the AnnounceTournament use case that were introduced by realizing the
change specified in Exercise 5-10.
5-12 Update the class diagrams of Figure 5-29 and Figure 5-31 to include the new objects
you identified in Exercise 5-11.
5-13 Draw a state machine describing the behavior of the AnnounceTournamentControl
object based on the sequence diagrams of Figures 5-26 through 5-28. Treat the sending
and receiving of each notice as an event that triggers a change of state.
Further Readings 255
Subsystems identified during the initial subsystem decomposition often result from
grouping several functionally related classes. These subsystems are good candidates for the
Facade design pattern and should be encapsulated under one class.
6.6 Exercises
6-1 Decomposing a system into subsystems reduces the complexity developers have to deal
with by simplifying the parts and increasing their coherence. Decomposing a system
into simpler parts usually increases a different kind of complexity: simpler parts also
means more parts and more interfaces. If cohesion is the guiding principle driving
256 Chapter 6 • System Design: Decomposing the System
developers to decompose a system into small parts, which competing principle drives
them to keep the total number of parts small?
6-2 In Section 6.4.2, we classified design goals into five categories: performance,
dependability, cost, maintenance, and end user. Assign one or more categories to each
of the following goals:
• Users must be given feedback within one second after they issue any command.
• The TicketDistributor must be able to issue train tickets, even in the event of a
network failure.
• The housing of the TicketDistributor must allow for new buttons to be installed
in case the number of fares increases.
• The AutomatedTellerMachine must withstand brute force attacks (i.e., users
attempting to discover a identification number by systematic trial).
6-3 You are developing a system that stores its data on a Unix file system. You anticipate
that you will port future versions of the system to other operating systems that provide
different file systems. Propose a subsystem decomposition that anticipates this change.
6-4 Older compilers were designed according to a pipe and filter architecture, in which
each stage would transform its input into an intermediate representation passed to the
next stage. Modern development environments, including compilers integrated into
interactive development environments with syntactical text editors and source-level
debuggers, use a repository architecture. Identify the design goals that may have
triggered the shift from pipe and filter to repository architecture.
6-5 Consider the model/view/control example depicted in Figures 6-17 and 6-16
a. Redraw the communication diagram of Figure 6-17 as a sequence diagram.
b. Discuss how the MVC architecture helps or hurts the following design goals:
• Extensibility (e.g., the addition of new types of views)
• Response time (e.g., the time between a user input and the time all views have
been updated)
• Modifiability (e.g., the addition of new attributes in the model)
• Access control (i.e., the ability to ensure that only legitimate users can access
specific parts of the model).
6-6 List design goals that would be difficult to meet when using a closed architecture with
many layers, such as the OSI example depicted in Figure 6-11.
6-7 In many architectures, such as the three- and four-tier architectures (Figures 6-22 and
6-23), the storage of persistent objects is handled by a dedicated layer. In your opinion,
which design goals have lead to this decision?
Exercises 303
7.8 Exercises
7-1 Consider a system that includes a Web server and two database servers. Both database
servers are identical: the first acts as a main server, and the second acts as a redundant
back-up in case the first one fails. Users use Web browsers to access data through the
Web server. They also have the option of using a proprietary client that accesses the
databases directly. Draw a UML deployment diagram representing the hardware/soft-
ware mapping of this system.
7-3 You are designing the access control policies for a Web-based retail store. Customers
access the store via the Web, browse product information, input their address and
payment information, and purchase products. Suppliers can add new products, update
product information, and receive orders.The store owner sets the retail prices, makes
tailored offers to customers based on their purchasing profiles, and provides marketing
services. You have to deal with three actors: StoreAdministrator, Supplier, and
Customer. Design an access control policy for all three actors. Customers can be
created via the Web, whereas Suppliers are created by the StoreAdministrator.
7-4 Select a control flow mechanism you find most appropriate for each of the following
systems. Because multiple choices are possible in most cases, justify your choices.
7-5 Why can you not describe boundary use cases during requirements elicitation or
analysis?
7-6 You are designing a caching subsystem that temporarily stores data retrieved over the
network (e.g., web pages) into a faster access storage (e.g., the hard disk). Due to a
change in requirements, you define an additional service in your subsystem for
configuring cache parameters (e.g., the maximum amount of hard disk the cache can
use). Which project participants do you notify?