The Object Primer Agile Modeling-Driven Developmen
The Object Primer Agile Modeling-Driven Developmen
The Object Primer Agile Modeling-Driven Developmen
net/publication/235616285
CITATIONS READS
329 18,364
1 author:
Scott W. Ambler
Disciplined Agile Consortium
122 PUBLICATIONS 3,663 CITATIONS
SEE PROFILE
All content following this page was uploaded by Scott W. Ambler on 11 March 2015.
Scott W. Ambler
PUBLISHED BY THE PRESS SYNDICATE OF THE UNIVERSITY OF CAMBRIDGE
The Pitt Building, Trumpington Street, Cambridge, United Kingdom
http://www.cambridge.org
A catalog record for this book is available from the British Library.
Foreword xvii
Preface xix
Acknowledgments xxiii
Chapter 1 • Introduction 1
1.1 The Structured Paradigm versus the Object-Oriented Paradigm 2
1.2 How Is This Book Organized? 3
1.3 How to Read This Book 5
1.4 What You Have Learned 7
ix
x The Object Primer
Glossary 475
References and Recommended Reading 499
Index 505
Developers are good at building systems right.
Chapter 1
Introduction
1
2 The Object Primer
DEFINITION
Paradigm. (pronounced para-dime) An overall strategy or viewpoint for doing
things. A paradigm is a specific mindset.
Chapter 1 • Introduction 3
Object
Object
Functions
and Data
Procedures Object Object
the real world, students know things (they have names, addresses, birth Figure 1-1.
dates, telephone numbers, and so on) and they do things (enroll in Comparing the
courses, drop courses, and pay tuition). Professors also know things (the structured and
courses they teach and their names) and they do things (input marks and object-oriented
paradigms
make schedule requests). From a systems perspective, rooms know things
(the building they’re in and their room number) and should be able to
do things, too (such as tell you when they are available and enable you
to reserve them for a certain period of time). Courses also know things
(their title, description, and who is taking the course) and should be able
to do things (such as letting students enroll in them or drop them).
To implement this system, we would define a collection of classes (a class
is a generic representation of similar objects) that interact with each other.
For example, we would have “Course,” “Student,” “Professor,” and “Room”
classes. The collection of these classes would make up our application,
which would include both the functionality (the program) and the data.
As you can see, the OO approach results in a completely different view For individuals,
of what an application is all about. Rather than having a program that OO is a whole new
accesses a database, we have an application that exists in what is called way to think.
For organizations,
an object space. The object space is where both the program and the data
OO requires a
for the application reside. I discuss this concept in further detail in Chap- complete change
ter 5 but, for now, think of the object space as virtual memory. in its system
development
culture.
1.2 How Is This Book Organized?
The Object Primer covers leading-edge OO techniques and concepts that
have been proven in the development of real-world applications. It covers
in detail why you should learn this new approach called object orientation,
requirements techniques, such as use cases and CRC modeling, OO
4 The Object Primer
DEFINITIONS
Class. A template from which objects are created (instantiated). Although in
the real world Doug, Wayne, and Bill are all “student objects,” we would model
the class “Student” instead.
Object space. The memory space, including all accessible permanent storage,
in which objects exist and interact with one another.
Object. A person, place, thing, concept, event, screen, or report. Objects both
know things (that is, they have data) and they do things (that is, they have
functionality).
Object-oriented paradigm. A development strategy based on the concept of
building systems from reusable components called objects.
OO. An acronym used interchangeably for two terms: Object-oriented and
object orientation. For example, when we say OO programming, we really
mean object-oriented programming. When we say this is a book that describes
OO, we really mean this it is a book that describes object orientation.
The Object Primer concepts, OO analysis and design using the UML modeling techniques,
covers everything OO programming, OO testing, and the OO software process. The book
you need to know to ends with a discussion of how to continue your learning process, including
get you started in
descriptions of common object-oriented technologies and techniques you
OO development.
might want to consider applying on software projects.
Figure 1-2 depicts the organization of The Object Primer, showing the
individual chapters and the relationships between them. Table 1-1 sum-
marizes the contents of each chapter. On the left side of the diagram are
the chapters that describe the fundamental activities of the software
process, such as gathering requirements, object-oriented analysis, and
object-oriented programming. The arrows between the boxes represent
the general relationships between the chapters: you see the chapters
describing gathering requirements, validating requirements, and object-
oriented analysis are closely related to one another. Chapter 9 covers
object-oriented testing and describes testing techniques that should be
used to validate your analysis, design, and programming efforts. Along
the right-hand side of Figure 1-2 are listed several “supporting” chapters,
chapters that present material that is critical to your understanding of
the object-oriented paradigm.
DEFINITION
Unified Modeling Language (UML). The definition of a standard modeling
language for object-oriented software, including the definition of a modeling
notation and the semantics for applying it as defined by the Object Manage-
ment Group (OMG).
Chapter 1 • Introduction 5
Object-Oriented Object-Oriented
Analysis Concepts
(Chapter 6) (Chapter 5)
Figure 1-2.
The organization of
1.3 How to Read This Book this book
Chapter Description
2: A New Software Paradigm Discussion of the advantages and disadvantages of object ori-
entation, why objects are here to stay, and an overview of the
software process.
10: Object-Oriented Software Process Overview of the Object-Oriented Software Process (OOSP)
and the enhanced lifecycle of the Unified Process.
11: Where to Go From Here Discussion of what you need to do to continue your OO
learning process, including a description of leading object
technologies and techniques such as Java, Enterprise Java-
Beans (EJB), C++, and component-based development.
Chapter 1 • Introduction 7
DEFINITION
Full lifecycle object-oriented testing (FLOOT). A testing methodology for
object-oriented development that comprises testing techniques that, taken
together, provide methods to verify that your application works correctly at
each stage of development.
Students
Like the first group of people, you should also read this book from cover
to cover. Furthermore, you should read this book two or three weeks
before your midterm test on object orientation, and not the night before
the exam. This stuff takes a while to sink in (actually it takes much
longer than a few weeks, but there’s only so much time in a school term).
Chapter 6
Determining What to
Build: Object-Oriented
Analysis
How to develop a system use case model from an essential use case model
How to develop sequence diagrams
How to develop a conceptual class model from a domain model
How to develop activity diagrams
How to develop a user interface prototype
How to evolve your supplementary specification
How to apply the Object Constraint Language (OCL)
How to apply analysis patterns
How to write user documentation
How to apply packages on your diagrams
Your requirements model, although effective for understanding what your users
want to have built, is not as effective at understanding what will be built.
Object-oriented analysis techniques, such as system use case modeling, sequence
diagramming, class modeling, activity diagramming, and user interface
prototyping are used to bridge the gap between requirements and system design.
181
182 The Object Primer
Requirements The purpose of analysis is to understand what will be built. This is similar
engineering to requirements gathering, described in Chapter 3, the purpose of which
focuses on
is to determine what your users want to have built. The main difference
understanding
is that the focus of requirements gathering is on understanding your
users and their
usage, whereas users and their potential usage of the system, whereas the focus of analy-
analysis focuses sis shifts to understanding the system itself.
on understanding Figure 6-1 depicts the main artifacts of your analysis efforts and the
what needs to be relationships between them. The solid boxes indicate major analysis arti-
built. facts, whereas the dashed boxes represent your major requirements arti-
facts. As with the previous Figure 3-1, the arrows represent “drives”
relationships; for example, you see that information contained in your
CRC model affects information in your class model and vice versa. Figure
6-1 has three important implications. First, analysis is an iterative process.
Essential
Use Case
Use Case
Model
Model
Sequence Activity
Business Rules
Diagram Diagram
Class Model
CRC Model
(Analysis)
DEFINITIONS
Activity diagram. A UML diagram used to model high-level business processes or the transitions
between states of a class (in this respect, activity diagrams are effectively specializations of state chart
diagrams).
Class diagram. Shows the classes of a system and the associations between them.
Class model. A class diagram and its associated documentation.
Class Responsibility Collaborator (CRC) card. A standard index card that has been divided into
three sections: one indicating the name of the class the card represents, one listing the responsibilities
of the class, and the third listing the names of the other classes with which this one collaborates to ful-
fill its responsibilities.
Class Responsibility Collaborator (CRC) model. A collection of CRC cards that model all or part
of a system.
Diagram. A visual representation of a problem or solution to a problem.
Essential use case. A simplified, abstract, generalized use case that captures the intentions of a user
in a technology and implementation independent manner.
Essential use case model. A use case model comprised of essential use cases.
Essential user interface prototype. A low-fidelity prototype of a system’s user interface that mod-
els the fundamental, abstract characteristics of a user interface.
Model. An abstraction describing a problem domain and/or a solution to a problem domain. Tradi-
tionally models are thought of as diagrams plus their corresponding documentation, although non-
diagrams, such as interview results and collections of CRC cards, are also considered to be models.
Project stakeholder. Anyone who could be materially affected by the implementation of a new sys-
tem or application.
Prototype. A simulation of an item, such as a user interface or a system architecture, the purpose of which
is to communicate your approach to others before significant resources are invested in the approach.
Sequence diagram. A diagram that models the sequential logic, in effect, the time ordering of messages.
Use case. A sequence of actions that provide a measurable value to an actor.
Use case diagram. A diagram that shows use cases, actors, and their interrelationships.
Use case model. A model comprised of a use case diagram, use case definitions, and actor defini-
tions. Use case models are used to document the behavior requirements of a system.
User interface (UI). The user interface of software is the portion the user directly interacts with,
including the screens, reports, documentation, and software support (via telephone, electronic mail,
and so on).
User interface flow diagram. A diagram that models the interface objects of your system and the
relationships between them. Also know as an interface-flow diagram, a windows navigation diagram,
or an interface navigation diagram.
User interface prototype. A prototype of the user interface (UI) of a system. User interface proto-
types could be as simple as a hand-drawn picture or a collection of programmed screens, pages, or
reports.
Chapter 6 • Determining What to Build: Object-Oriented Analysis 185
DEFINITIONS
Extend association. A generalization relationship where an extending use case
continues the behavior of a base use case. The extending use case accomplishes
this by inserting additional action sequences into the base use case sequence.
This is modeled using a use case association with the <<extend>> stereotype.
Include association. A generalization relationship denoting the inclusion of
the behavior described by a use case within another use case. This is modeled
using a use case association with the <<include>> stereotype Also known as a
“uses” or a “has-a” relationship.
Chapter 6 • Determining What to Build: Object-Oriented Analysis 187
continued on page 90
188 The Object Primer
Student System
1. The student wants to enroll in a seminar. 3. The system verifies the student is eligible to enroll
2. The student inputs his name and student number in seminars at the university, according to business
into the system via “UI23 Security Login Screen.” rule “BR129 Determine Eligibility to Enroll.”
4. The system displays “UI32 Seminar Selection
Screen,” which indicates the list of available seminars.
5. The student indicates the seminar in which she 6. The system validates the student is eligible to
wants to enroll. enroll in the seminar, according to the business
rule “BR130 Determine Student Eligibility to Enroll
in a Seminar.”
7. The system validates the seminar fits into the
existing schedule of the student, according to the
business rule “BR143 Validate Student Seminar
Schedule.”
8. The system calculates the fees for the seminar
based on the fee published in the course catalog,
applicable student fees, and applicable taxes.
Apply business rules “BR 180 Calculate Student
Fees” and “BR45 Calculate Taxes for Seminar.”
9. The system displays the fees via “UI33 Display
Seminar Fees Screen.”
10. The system asks the student whether she still
wants to enroll in the seminar.
11. The student indicates she wants to enroll in the 12. The system enrolls the student in the seminar.
seminar. 13. The system informs the student the enrollment
was successful via “UI88 Seminar Enrollment Sum-
mary Screen.”
14. The system bills the student for the seminar,
according to business rule “BR100 Bill Student for
Seminar.”
15. The system asks the student if she wants a
printed statement of the enrollment.
16. The student indicates she wants a printed 17. The system prints the enrollment statement
statement. “UI89 Enrollment Summary Report.”
18. The use case ends when the student takes the
printed statement.
Figure 6-3.
Basic course of
action for “Enroll in
Seminar” written in
action-response style
190 The Object Primer
Figure 6-4.
The opportunities
for reuse in use case
models
Registrar
Enroll in Enroll in
<<include>>
University Seminar
Student
<<extend>>
International
Student
case. Notice how the identifier and the name of the use case is indicated.
If several use cases extended this one from the same point, then each one
would need to be listed. A condition statement, such as “Condition:
Enrollee is an international student,” could have been indicated immedi-
ately following the name of the use but, in this example, it was fairly
obvious what was happening.
case. The best way to think of an include association is that it is the invo-
cation of a use case by another one. In Figure 6-4, notice that the use case
Figure 6-5.
4. The system displays “UI43 Student Information Entry.” [Extension Point: Documenting an
UC34 Enroll International Student In University.] extension point
5. The student… within a use case
192 The Object Primer
DEFINITIONS
Base use case. A use case extended by another via an extend association.
Extending use case. A use case that extends another use case via an extend
association.
Extension point. A marker in a use case where extension is allowed.
“Enroll in University” includes the use case “Enroll in Seminar”; the nota-
tion for doing so is simply a normal use case association with the stereo-
type of <<include>>. Figure 6-6 presents an example of how you would
indicate where the use case is included in the logic of the including use
case. Similar to calling a function or invoking an operation within source
code, isn’t it? Object-oriented programming is covered in Chapter 8.
You use include associations whenever one use case needs the behav-
ior of another. Introducing a new use case that encapsulates similar logic
that occurs in several use cases is quite common. For example, you may
discover that several use cases need the behavior to search for and then
update information about students, indicating the potential need for an
“Update Student Record” use case included by the other use cases.
As you would expect, the use case “Enroll in University” should list
“UC17 Enroll in Seminar” in its “Includes” list. Why should you bother
maintaining an “Includes” and an “Extends” list in your use cases? The
answer is simple: Your use cases should stand on their own; you shouldn’t
expect people to have your use case diagram in front of them. Yes, it
would be nice if everyone has access to the use case diagram because it
also contains this information, but the reality is that sometimes you use
different tools to document each part of your model. For example, your
diagrams could be drawn using a drawing package and your use cases
documented in a word processor. Some of your project stakeholders may
have access to the word processor you are using, but not the drawing
package. The main disadvantage of this approach is you need to main-
tain these two lists in parallel with the diagram, the danger being they
may become unsynchronized.
Figure 6-6.
Indicating the 8. The student indicates the seminar(s) she wants to take via the use case
inclusion of a UC 17 Enroll in Seminar.
use case 9. The student…
Chapter 6 • Determining What to Build: Object-Oriented Analysis 193
6.1.2.3 Inheritance
Use cases can inherit from other use cases, offering a third opportunity to Use cases may
indicate potential reuse. Figure 6-4 depicts an example of this, showing inherit from other
that “Enroll Family Member in University” inherits from the “Enroll In use cases.
University” use case. Inheritance between use cases is not as common as
either the use of extend or include associations, but it is still possible. The
inheriting use case would completely replace one or more of the courses
of action of the inherited use case. In this case, the basic course of action
is completely rewritten to reflect that new business rules are applied when
the family member of a professor is enrolling at the university. Family
members are allowed to enroll in the school, regardless of the marks they
earned in high school; they don’t have to pay any enrollment fees, and
they are given top priority for enrollment in the university.
Inheritance between use cases should be applied whenever a single condi- Apply inheritance
tion, in this case, the student is a family member of a professor, would result between use cases
in the definition of several alternate courses. Without the option to define when a single
condition would
an inheriting use case, you need to introduce an alternate course to rework
result in several
the check of the student’s high-school marks, the charging of enrollment alternate courses.
fees, and for prioritization of who is allowed to enroll in the given semester.
The inheriting use case is much simpler than the use case from which
it inherits. It should have a name, description, and identifier, and it
should also indicate from which use case it inherits in the “Inherits
From” section. In sections that you replace, you may need to rewrite the
preconditions, postconditions, or courses of action. If something is not
replaced, then leave that section blank, assuming it is inherited from the
parent use case (you might want to put text, such as “see parent use
case,” in the section).
The fourth opportunity for indicating potential reuse within use case Actors may inherit
models occurs between actors: An actor on a use case diagram can inherit from other actors.
from another actor. An example of this is shown in Figure 6-4, where the
“International Student” actor inherits from “Student.” An international stu-
dent is a student, the only difference being he or she is subject to different
rules and policies (for instance, the international student pays more in
tuition). The standard UML notation for inheritance, the open-headed
arrow, is used and the advice presented about the appropriate use of inheri-
tance still applies: It should make sense to say the inheriting actor is or is
like the inherited actor.
the actor is an external system, then you need to develop a system inter-
face, perhaps a data file transfer or a real-time online link to the external
system. For example, in the “Enroll in Seminar” use case of Figure 6-2,
the Student actor interacts with the system via several major UI compo-
nents, particularly “UI23 Security Login Screen,” “UI32 Seminar Selec-
tion Screen,” “UI33 Display Seminar Fees Screen,” “UI88 Seminar
Enrollment Summary Screen,” and “UI89 Enrollment Summary Report.”
You should be able Second, use cases are often written under the assumption that you can
to exit from a use exit at any time. For example, in the middle of the “Enroll in Seminar”
case at any time. use case, the student may decide to give up and try again later or the sys-
tem may crash because the load on it is too great. The description of the
use case doesn’t include these as alternate courses because it would
greatly increase the complexity of the use case without adding much
value. Instead, it is assumed, if one of these events occurs, that the use
case simply ends and the right thing will happen. However, your subject
matter experts (SMEs) may want to define nonfunctional requirements
that describe how situations such as this should be handled.
Beware of the “use Third, in my opinion, use case modeling has received far more atten-
case driven” hype tion than it actually deserves. Yes, it is a useful technique but no, it isn’t
of consultants and the be-all-and-end-all of requirements and analysis modeling. You saw in
tool vendors. Chapter 3 that essential use case modeling is one technique of several
you can use to gather requirements and, as you see in this chapter, it is
also one of several techniques to perform object-oriented analysis. Don’t
let the marketing hype of CASE tool vendors and object-oriented consul-
tants deceive you into thinking everything should be “use case driven.”
Use case modeling is merely one of many important techniques you
should have in your modeling toolkit.
Include, extend, Fourth, although the reuse techniques— extend associations, include
and inheritance associations, and inheritance—are useful, don’t overuse them. Include
associations associations and, to a lesser degree, extend associations, lead to func-
between use cases tional decomposition within your use case model. The problem is use
can lead to
cases are not meant to describe functions within your source code; they
functional
decomposition if
are meant to describe series of actions that offer value to actors. A good
you are not rule of thumb to use is if you are able to describe a use case with a single
careful. sentence, then you have likely decomposed it too much, something that
occurs when you apply include associations too often. Another rule of
thumb is, if you have more than two levels of include associations, for
example, if use case A includes use case B, which includes use case C,
then two levels of include exist, and then you are in danger of functional
decomposition. The same can be said of extend associations between use
cases, as well as inheritance.
Chapter 6 • Determining What to Build: Object-Oriented Analysis 195
DEFINITIONS
Major user interface element. A large-grained item, such as a screen, HTML
page, or report.
Minor user interface element. A small-grained item, such as a user input
field, menu item, list, or static text field.
Supplementary specification. An artifact where all requirements not contained
in your use case model, user interface model, or domain model are documented.
198 The Object Primer
student number
isEligible(name, studentNumber)
3. System verifies student <<create>>
theStudent
theStudent
<<destroy>> Note: Need to
X flesh this message
<<create>> out more.
4. System displays seminar list
selection
5. Students picks seminar
isEligibleToEnroll(theStudent) qualifications()
6. System determines eligibility to enroll
getSchedule()
determineFit(seminar)
7. System determines schedule fit
<<create>>
9. System displays fees
10. System verifies student wishes to enroll
11. Students indicates yes. verification
enrollStudent(theStudent)
12. System enrolls student in seminar X
Figure 6-7.
A UML sequence
diagram for the basic
course of action for
Figure 6-2
200 The Object Primer
Messages fulfill the logic of the steps of the use case, summarized
down the left-hand side of the diagram. Notice how the exact wording of
the use case steps isn’t used because the steps are often too wordy to fit
nicely on a diagram. What is critical is that the step numbers correspond
to those in the use case and that the general idea of the step is apparent
to the reader of the diagram.
Stereotypes may Notice the use of stereotypes throughout the diagram. For the boxes, I
be applied to applied the stereotypes <<actor>>, <<controller>>, and <<UI>> indicating
actors, objects, that they represent an actor, a controller class, or a user interface (UI)
classes, and class, respectively. For now, a controller class is a placeholder for one or
messages on
more classes that would be fleshed out during design (Chapter 7) to
sequence
implement the business logic of your system. As you see in Chapter 7,
diagrams.
you want to layer your system, separating your user interface logic, busi-
ness logic, system logic, and persistence logic away from each other.
Stereotypes are also used on messages. Common practice on UML dia-
grams is to indicate creation and destruction messages with the stereo-
types of <<create>> and <<destroy>>, respectively. For example, you see
that the “:SecurityLogon” object is created in this manner (actually, this
message would likely be sent to the class that would then result in a
return value of the created object, so I cheated a bit). This object later
DEFINITIONS
Anonymous object. An object appearing on the diagram that hasn’t been
given a name; instead, the label is simply an indication of the class, such as
“: Invoice.”
Classifier. A mechanism that describes behavioral or structural features. Classi-
fiers include use cases, classes, interfaces, and components.
Lifeline. Represents, in a sequence diagram, the life span of an object during
an interaction.
Method. Something a class or object does. A method is similar to a function or
procedure in structured programming and is often referred to as an operation
or member function in object development.
Message-invocation box. The long, thin, vertical boxes that appear on sequence
diagrams, which represent invocation of an operation on an object or class.
Signature. The combination of the name, parameter names (in order), and
name of the return value (if any) of a method.
Static method. A method that operates at the class level, potentially on all
instances of that class.
Stereotype. A stereotype denotes a common usage of a modeling element.
Stereotypes are used to extend the UML in a consistent manner.
Chapter 6 • Determining What to Build: Object-Oriented Analysis 201
DEFINITIONS
C++. A hybrid object-oriented programming language that adds object-oriented
features to the C programming language.
Constructor. A method, typically a static one, whose purpose is to instantiate
and, optionally, initialize an object.
Controller. A class that implements business/domain logic, coordinating sev-
eral objects to perform a task.
Destructor. A method whose purpose is to remove an object completely from
memory.
Goldplating. The addition of extraneous features to a system.
Java. An object-oriented programming language based on the concept of
“write once, run anywhere.”
Note. A modeling construct for adding free-form text to the UML diagrams.
You may have heard terms such as dynamic modeling and static modeling TIP
bantered about by other developers familiar with object-oriented modeling
techniques. You may even have heard arguments about the merits of each Sequence
style. Dynamic modeling techniques focus on identifying the behavior within Diagrams Are
your system. These techniques include sequence diagramming and activity Dynamic
diagramming (both of which are described in this chapter) and collaboration
diagramming, described in Chapter 7. Static modeling focuses on the static
aspects of your system, including the classes, their attributes, and the associations
between classes. Class models, described in this chapter, are the main artifact
of static modeling, as are persistence models, which are described in Chapter
7. Both dynamic and static modeling techniques are required to specify an
object-oriented system adequately, which makes the “dynamic modeling
versus static modeling” debates questionable at best.
The sequence diagram of Figure 6-8 is simpler than that of Figure 6-7;
this is generally the case of alternate courses. I modeled the return value
from the “isEligibleToEnroll(theStudent)” message because this is what
causes the alternate course to occur in the first place. This arguably points
to the need always to model return values in your sequence diagrams. I
still prefer to keep my diagrams as simple as possible, though, so I model
them only when the information is vital to my understanding of the
logic. I also chose to show the ineligibility notice as its own user- interface
element, once again bordering on a design decision that would need to be
reflected in the user interface prototype. I also modeled that the prerequi-
sites list is displayed as part of the seminar details user interface element,
which is more than the use case currently calls for. This implies that I
should verify the change with my SMEs because I have effectively
increased the requirements although, by doing so, I have likely indicated Figure 6-8.
an opportunity for both reuse and an overall simplification of the poten- A UML sequence
diagram for an
alternate course
Enroll In Seminar
Alternate Course of
Action: Student Does
not Have Prerequisites A Student :EnrollInSeminar :IneligibilityNotice :SeminarDetails seminar:Seminar
<<actor>> <<controller>> <<UI>> <<UI>>
SD #: UC17-01B
isEligibleToEnroll(theStudent)
B.6. System determines ineligibility to enroll
false
<<create>>
B.7. System informs the student of ineligibility
B.8. System informs the student of <<create>>
prerequisites
B.9. Use case resumes at step 4
204 The Object Primer
tial design. As you can see with this example, the line between analysis
and design is fuzzy with object-oriented development; experienced devel-
opers new to objects can take time to get used to this. Finally, I left the
“Student” actor in the diagram, even though no direct interaction occurs
at this point because this actor is referred to in the steps of the use case.
1
Stereotypes in the UML typically begin with a lowercase letter. However, because I am
using the term “UI” for the stereotype label, instead of “user interface,” I have chosen
to capitalize it. Also, in Chapter 3, I was using the stereotype <<Actor>> instead of
<<actor>> on the Class Responsibility Collaborator (CRC) cards. I did this for two rea-
sons. First, CRC models are not part of the UML and, therefore, don’t have comply
with UML practices. Second, I did it to show you the world won’t end if you break the
rules a bit. I’ve lot track of the amount of time, easily in the hundreds of hours, that
I’ve wasted in conversations during modeling sessions over nitpicky issues such as this.
Your goal is to model your system accurately in a way that is understandable to the
people involved; whether you use <<Actor>> or <<actor>> as a stereotype is barely rele-
vant when the big picture is taken into consideration.
206 The Object Primer
13. Update your use case model. As you are sequence diagram-
ming, you may find errors in your original use case logic, errors
that need to be fixed on both your sequence diagram(s) and in
your use case(s). As always, validate any use case changes with
your SMEs first.
DEFINITION
Transitory object. An object that is not saved to permanent storage.
208 The Object Primer
DEFINITION
Computer-aided system engineering (CASE) tool. Software that supports
the creation of models of software-oriented systems.
(1999) point out that if you are having problems getting started drawing
sequence diagrams for a use case, then you likely wrote the use case
incorrectly and should reconsider its logic. They also point out that
sequence diagramming is the primary vehicle for allocating behavior.
During analysis, you will begin to add solution-space objects to the
problem-domain objects (from your CRC model), including controller
and user interface objects. Furthermore, during design, Rosenberg and
Scott (1999) also point out that you will infrastructure objects such as
system and persistence objects, scaffolding, and other helper objects into
your models.
2
In the original edition of this book, written in 1995, I argued for, and then used, the
term “class model,” instead of “object model,” for the simple reason that you use them
to model classes and their relationships, not objects.
Chapter 6 • Determining What to Build: Object-Oriented Analysis 209
DEFINITIONS
Problem space. The scope of your business domain being addressed by your
system.
Solution space. The problem space being addressed by your system plus the
nondomain functionality required to implement your system.
needed to actually build it. Luckily, those details have been captured in
the notes taken down by the scribe(s) during CRC modeling. Figure 6-9
depicts the CRC model we developed in Chapter 3, the “SecurityLogon”
class identified in the sequence diagrams earlier has been introduced to
CRC model, and Figure 6-10 depicts the UML class diagram that would
be created based on that CRC model.
For each card in the CRC model, you create a concrete class in the class
diagram, with the exception of cards that represent actors (actors exist in the Figure 6-9.
real world). Notice how the names stayed the same (spaces were removed A CRC model for
the university
Professor
Name
Seminar
Address
Phone number
Email address
Salary
Transcript <<UI>>
Provide information
Seminars instructing
**See the prototype** Student
Student <<Actor>> Get student info Seminar
Get seminars student Professor .
Provide information Enroll in Seminar took Enrollment Record
about self Transcript Determine average Seminar
Request to enroll in mark
seminar Name
Output self Student
Request Transcript Seminar number
Professor
Fees
Waiting list
Enrolled students
Enroll in Seminar <<UI>> Instructor
Add student
**See the prototype** Seminar Drop student
Enable seminar search Professor
Display seminar list
Display seminar fees Student
Display professor info
Name Enrollment
Address Record
Phone number
Email address
Student number
Average mark received
SecurityLogon <<UI>> Validate identifying info
Provide list of seminars
**See the prototype** Student taken
Request identifying
info for student
Enrollment Record
EnrollmentRecord
marksReceived
SecurityLogon
<<UI>> getAverageToDate()
enrolled getFinalMark()
acceptStudentID() in enrolled
acceptStudentName()
in
validateStudent()
Student
name Seminar
Transcript
address name
<<UI>>
phoneNumber seminarNumber
emailAddress fees
getStudent() studentNumber on waiting list waitingList
getSeminars() averageMark
determineAverage() addStudent(student)
isEligible (name, dropStudent(student)
output() studentNumber)
getSeminarsTaken()
EnrollInSeminar
<<UI>> instructs
searchForSeminar()
displaySeminarList() Professor
displaySeminarFees() name
displayProfessor() address
phoneNumber
emailAddress
salary
Figure 6-10. getInformation()
A UML class diagram
based on the CRC
model
from the names to follow the naming convention of ClassName). Next, the
collaborators on CRC cards indicate the need for an association, aggregation
association, or dependency between classes. I modeled dependencies
between user interface classes and the business classes with which they col-
Collaborations from laborate because user interface classes are transitory in nature, implying the
a user interface associations they are involved with are transitory and, hence, should be
class implies a modeled as dependencies. Whenever a collaboration occurred between two
dependency, whereas
business classes, I modeled an association for now. As you see later, these
collaborations
from business/
associations may, in fact, prove to be aggregation associations but, for now, it
domain classes is good enough simply to have modeled the line.
imply either Consider the associations modeled in Figure 6-10. The “waiting list”
association or association between “Seminar” and “Student” was added, modeling the
aggregation similarly named responsibility on the “Seminar” CRC card. I could have
between the classes. added an attribute in the “Seminar” class called “waitingList” but,
instead, chose to model it as an association because that is what it actu-
ally represents: that seminar objects maintain a waiting list of zero or
more student objects. In Chapter 5, I showed that associations are imple-
mented as a combination of attributes and operations so, frankly, you
may as well add the attribute to the model now and get it over with. The
“waiting list” association is unidirectional because there was neither a
Chapter 6 • Determining What to Build: Object-Oriented Analysis 211
DEFINITION
Concrete class. A class that has objects instantiated from it.
corresponding collaborator indicated by the “Student” card nor did a Associations are
responsibility indicate that the “Student” card had knowledge of being bidirectional only
on a waiting list. I modeled an “enrolled in” association between the if they need to be
traversed in both
“Student” and “EnrollmentRecord” classes to support the similarly
directions.
named responsibility on the “Student” CRC card. For this association, it
appears student objects know what enrollment records they are involved
with, recording the seminars they have taken in the past, as well as the
seminars in which they are currently involved. This association would be
traversed to calculate their student object’s average mark and to provide
information about seminars taken. There is also an “enrolled in” associa-
tion between “EnrollmentRecord” and “Seminar” to support the capabil-
ity for student objects to produce a list of seminars taken. The “instructs”
association between the “Professor” class and the “Seminar” class is bidi-
rectional because professor objects know what seminars they instruct
(the Seminar’s instructing responsibility) and seminar objects know who
instructs them (the Instructor responsibility).
Other than the previously noted exceptions, the responsibilities on Responsibilities
the CRC cards were modeled either as attributes or methods of the corre- are usually
sponding classes. The “Student” class is interesting because I chose to modeled as
attributes or
model the “Average mark received” responsibility as an attribute and not
methods.
a method. How this responsibility is actually implemented is a design
decision, one I don’t need to make now. I have made a good guess as to
how to implement this responsibility and moved on to other issues. It is
too early in the modeling process to worry about nitpicky issues like this:
The “Student” class could go away, based on another design decision
(unlikely, but…), so why invest a lot of effort getting the details right
when close enough works just as well? My style is to name attributes and
methods using the formats attributeName and methodName(parameter-
Name), respectively, which happen to be the common naming conven-
tions for both Java (Vermeulen et al., 2000) and C++.
Also notice, in Figure 6-10, how I haven’t modeled the visibility of the
attributes and methods to any great extent. Visibility is an important
issue during design but, for now, it can be ignored. Also notice, I haven’t
defined the full method signatures for the classes. Yes, I have indicated
the parameters, but not their type. And I haven’t indicated the return
value from each method either, another task I typically leave to design.
Now consider the user interface classes. I didn’t bother to list the
attributes because they are modeled well enough by the prototype and
212 The Object Primer
DEFINITIONS
Bidirectional association. An association that may be traversed in both directions.
Unidirectional association. An association that may be traversed in only one
direction.
Visibility. The level of access external objects have to an item, such as an
object’s attributes or methods, or even to a class itself.
Modeling user eventual user interface design. The purpose of models is to describe your
interface classes on system adequately, rarely to describe it thoroughly. Yes, I could create
class diagrams detailed classes for each UI class in my model, but what value would that
often adds a lot of
be? It sounds like a lot of work for little return, particularly when more
clutter without
than enough details are in the user interface model already. Also, as you
adding much
useful information. can see in Figure 6-10, the UI classes have made quite a mess of the dia-
gram, requiring the modeling of a lot of dependencies that add signifi-
cant clutter without communicating much valuable information. This
information could be better recorded as part of your user interface
model; a simple spreadsheet listing each major UI element and the busi-
ness classes on which they are dependent should be sufficient.
Figure 6-11 presents a revised version of Figure 6-10; the user interface
classes have been removed and the multiplicity of the associations have
been modeled. Based on what the SMEs tell you and on the information
contained in the notes your scribe(s) took as part of requirements gather-
ing, you should be able to make educated guesses at the multiplicities of
each association. In Figure 6-11, I was able to determine with certainty,
based on this information, the multiplicities for all but one association
and, for that one, I marked it with a note to myself. Notice my use of
question marks in the note. As mentioned in Chapter 5, my style is to
mark unknown information on my diagrams this way to remind myself
that I need to look into it.
Model complex In Figure 6-11, I also modeled a UML constraint, in this case “{ordered
or important FIFO},” on the association between “Seminar” and “Student.” The basic
concepts on your idea is that students are put on the waiting list on a first-come, first-out
UML diagrams
(FIFO) basis. In other words, the students are put on the waiting list in
using OCL.
order. UML constraints are used to model complex and/or important
information accurately in your UML diagrams. UML constraints are mod-
eled using the format “{constraint description}” format, where the con-
straint description may be in any format, including predicate calculus.
Fowler and Scott (1997) suggest that you focus on readability and under-
standability and, therefore, suggest using an informal description. Con-
straints are described in further detail in Section 6.6.1.
Chapter 6 • Determining What to Build: Object-Oriented Analysis 213
EnrollmentRecord
1 enrolled in 1..* 1..* enrolled in 1
Student marksReceived Seminar
name getAverageToDate() name
address getFinalMark() seminarNumber
phoneNumber fees
{ordered, FIFO}
emailAddress 0..* on waiting list 0..* waitingList
studentNumber addStudent(student)
averageMark 0..* dropStudent(student)
isEligible (name,
studentNumber)
Professor
getSeminarsTaken()
name instructs
address
0..1
phoneNumber
emailAddress
salary
getInformation()
Figure 6-11.
Once you have converted the information contained in your CRC The revised class
model into an initial UML class model, you are then ready to continue diagram
fleshing out your model with added detail. Class models contain a
wealth of information and can be used for both the analysis and design
of systems. To create and evolve a class model, you need to model:
• Classes
• Methods
• Attributes
• Associations
• Dependencies
• Inheritance relationships
• Aggregation associations
• Association classes
which objects are created. Classes form the main building blocks of an
object-oriented application. Two of the steps of CRC modeling included the
finding of classes and the finding of responsibilities. Classes represent a col-
lection of similar objects. For example, although thousands of students
attend the university, you would only model one class, called “Student,”
which would represent the entire collection of students.
Classes are modeled as rectangles with three sections: the top section for
the name of the class, the middle section for the attributes of the class, and
the bottom section for the methods of the class. The initial classes of your
model will be identified when you convert from your CRC model, as will
the initial attributes and methods. To describe a class, you define its attrib-
utes and methods. Attributes are the information stored about an object (or
at least information temporarily maintained about an object), while meth-
ods are the things an object or class does. For example, students have stu-
dent numbers, names, addresses, and phone numbers. Those are all
examples of the attributes of a student. Students also enroll in courses, drop
courses, and request transcripts. Those are all examples of the things a stu-
dent does, which get implemented (coded) as methods. You should think of
methods as the object-oriented equivalent of functions and procedures.
An important aspect of analysis is to model your classes to the appropri-
ate level of detail. Consider the “Student” class modeled in Figure 6-11,
which has an attribute called “address.” When you stop and think about it,
addresses are complicated things. They have complex data, containing
street and city information for example, and they potentially have behav-
ior. An arguably better way to model this is depicted in Figure 6-12. Notice
how the “Address” class has been modeled to include an attribute for each
piece of data it comprises and two methods have been added: one to verify
it is a valid address and one to output it as a label (perhaps for an envelope).
By introducing the “Address” class, the “Student” class has become more
cohesive. It no longer contains logic (such as validation) that is pertinent to
addresses. The “Address” class could now be reused in other places, such as
the “Professor” class, reducing your overall development costs. Further-
more, if the need arises to support students with several addresses—during
the school term, a student may live in a different location than his perma-
nent mailing address, such as a dorm—this is information the system may
TIP Use the terminology of your users in all your models. The purpose of
analysis is to understand the world of your users, not to foist your
Use the Terminology of artificial, technical terms on them. Remember, they’re the experts,
Your Users not you. In short, avoid geek-speak.
Chapter 6 • Determining What to Build: Object-Oriented Analysis 215
0..* offering of 1
Seminar Course
seminarNumber name
waitingList courseNumber
fees
addStudent(student) getFullName() Figure 6-13.
dropStudent(student) Normalizing the
“Seminar” class
216 The Object Primer
getFullName()
getCourseNumber()
setCourseNumber(number)
getFees()
setFees(amount)
getName()
setName(name)
Figure 6-15 presents the class diagram that results3 when Figures 6-11,
6-12, and 6-13 are combined. Notice how “Professor””now references the
“Address” class, taking advantage of the work we did to improve the
“Student” class.
3
I have cheated a little and added the method “purchaseParkingPass()” to the “Profes-
sor” and “Student” classes, even though I didn’t have requirements for this. You’ll see
why I added this method later in Section 6.3.4 when I discuss inheritance.
EnrollmentRecord
1 enrolled in 1..* 1..* enrolled in 1 0..* offering of 1
Student marksReceived Seminar Course
getAverageToDate() seminarNumber name
name
getFinalMark() waitingList courseNumber
phoneNumber
fees
emailAddress {ordered, FIFO}
studentNumber 0..* on waiting list 0..* addStudent(student) getFullName()
averageMark dropStudent(student)
0..*
isEligible (name,
studentNumber) 0..1
Address Professor instructs
getSeminarsTaken() lives
purchaseParkingPass() street
at name
city lives at phoneNumber
state
1 1 0..1 emailAddress 0..1
postalCode
salary
country
getInformation()
validate()
outputAsLabel() purchaseParkingPass()
Figure 6-15.
Combined class
diagram
218 The Object Primer
DEFINITIONS
Class normalization. The process by which you refactor the behavior within
a class diagram in such a way as to increase the cohesion of classes while mini-
mizing the coupling between them.
Cohesion. The degree of relatedness within an encapsulated unit (such as a
component or a class).
Coupling. The degree of dependence between two items. In general, it is bet-
ter to reduce coupling wherever possible.
Getter. A method to obtain the value of a data attribute, or to calculate the
value, of an object or class.
Setter. A method that sets the value of a data attribute of an object or class.
Also known as a mutator.
associations are often two-way streets: not only do professors instruct semi-
nars, but also seminars are instructed by professors. This leads to questions
such as: how many professors can instruct any given seminar and is it possi-
ble to have a seminar with no one instructing it? The implication is you also
need to identify the cardinality and optionality of an association. Cardinality
represents the concept of “how many,” and optionality represents the con-
cept of “whether you must have something.” Important to note is the UML
chooses to combine the concepts of optionality and cardinality into the sin-
gle concept of multiplicity. The multiplicity of the association is labeled on
either end of the line, one multiplicity indicator for each direction (Table 6-1
summarizes the potential multiplicity indicators you can use).
Another option for associations is to indicate the direction in which
the label should be read. This is depicted using a filled triangle, an exam-
ple of which is shown on the “offering of” association between the “Sem-
inar” and “Course” classes of Figure 6-15. This marker indicates that the
association should be read “a seminar is an offering of a course,” instead
TIP For each class involved in an association, there is always a multiplicity for it.
When the multiplicity is one and one only (for example, one and one only
Always Indicate person may be President of the United States at any given time), then it is
the Multiplicity common practice not to indicate the multiplicity and, instead, to assume it is
“1.” I believe this is a mistake. If the multiplicity is “1,” then indicate it as such.
When something is left off a diagram, I can’t tell if that is what is meant or if the
modeler simply hasn’t gotten around to working on that aspect of the model
yet. I always assume the modeler hasn’t done the work yet.
Chapter 6 • Determining What to Build: Object-Oriented Analysis 219
Indicator Meaning
Professor Seminar
0..1 0..*
name seminarNumber
assistant
associate phoneNumber waitingList
0..* emailAddress {NAND}
salary addStudent(student)
0..1 0..* dropStudent(student)
getInformation()
instructor
0..1 advisor
mentors
DEFINITIONS
Cardinality. Represents the concept “how many?” in associations.
Optionality. Represents the concept “do you need to have it?” in associations.
Multiplicity. The UML combines the concepts of cardinality and optionality
into the single concept of multiplicity.
Recursive association. An association in which the objects involved in it are
instances of the same class. For example, people marry people.
Chapter 6 • Determining What to Build: Object-Oriented Analysis 221
Figure 6-17.
EnrollInSeminar Modeling
Seminar
<<UI>> dependencies
between classes
don’t want to have to write the same code repeatedly, you want a mechanism
that takes advantage of these similarities. Inheritance is that mechanism. Inheri-
tance models “is a” and “is like” relationships, enabling you to reuse existing
data and code easily. When A inherits from B, we say A is the subclass of B
and B is the superclass of A. Furthermore, we say we have “pure inheri-
tance” when A inherits all the attributes and methods of B. The UML
modeling notation for inheritance is a line with a closed arrowhead point-
ing from the subclass to the superclass.
In Figure 6-15, many similarities occur between the “Student” and
“Professor” classes. Not only do they have similar attributes, but they also
have similar methods. To take advantage of these similarities, I created a
new class called “Person” and had both “Student” and “Professor” inherit
from it, as you see in Figure 6-18. This structure would be called the “Per-
son” inheritance hierarchy because “Person” is its root class. The “Person”
class is abstract: Objects are not created directly from it, and it captures
the similarities between the students and professors. Abstract classes are
modeled with their names in italics, as opposed to concrete classes, classes
from which objects are instantiated, whose names are in normal text.
Both classes had a name, email address, and phone number, so these
attributes were moved into “Person.” The “purchaseParkingPass()”
method was also common between the two classes, so that was also
moved into parent class. By introducing this inheritance relationship to
the model, I reduced the amount of work to be performed. Instead of
implementing these responsibilities twice, they are implemented once, in
the “Person” class, and reused by “Student” and “Professor.”
An interesting aspect of Figure 6-18 is the association between “Per- Associations are
son” and “Address.” First, this association was pushed up to “Person” inherited.
because both “Professor” and “Student” had a “lives at” association with
DEFINITIONS
Dependency relationship. A dependency relationship exists between Class A
and B when instances of Class A interact with instances of Class B. Dependency
relationships are used when no direct relationship (inheritance, aggregation, or
association) exists between the two classes.
Persistence. The issue of how objects are permanently stored.
222 The Object Primer
DEFINITIONS
Abstract class. A class that doesn’t have objects instantiated from it.
Concrete class. A class that has objects instantiated from it.
Inheritance hierarchy. A set of classes related through inheritance. Also
referred to as a class hierarchy.
Inheritance. The representation of an is a, is like, or is kind of relationship
between two classes. Inheritance promotes reuse by enabling a subclass to ben-
efit automatically from all the behavior it inherits from its superclass(es).
Root class. The top-most class in an inheritance hierarchy.
Subclass. If Class B inherits from Class A, we say B is a subclass of A.
Superclass. If Class B inherits from Class A, we say A is a superclass of B.
Person Address
name street
phoneNumber city
0..1 lives at 1
emailAddress state
postalCode
purchaseParkingPass() country
validate()
outputAsLabel()
Student Professor
Figure 6-18.
studentNumber salary
Applying the
averageMark getInformation() concept of
inheritance in a
isEligible (name, class diagram
studentNumber)
getSeminarsTaken()
associations. In Figure 6-19, you see a simple class model depicting the rela-
tionships between “Program,” (a program is a collection of courses that lead
to a degree) and the “Course” class. A course may be part of one or more
programs—some courses such as “ARC 305 Medieval Gardening Tools” are
for general interest only and are not part of a program—and any given pro-
gram has one or more courses in it. Also notice how an association exists
between “Program” and “Course” representing that some courses are rec-
ommended for a program, but are not officially offered as part of them (my
SMEs told me this). For example, the course “CSC 148 Introduction to
Computer Science” is recommended for the engineering, business, and
physics programs within the university. It made sense to model this rela-
tionship with an association instead of an aggregation because it isn’t true
that a recommended course is part of a program.
In the class diagram of Figure 6-15, I was lucky because I used similar names for TIP
these attributes in both classes: “name,” “emailAddress,” and “phoneNumber,”
respectively. However, you will often find situations where one class has an Sometimes
attribute called “name,” whereas another one has “firstName,” “middleInitial,” Opportunities
and “lastName.” You then need to decide whether these are, in fact, the same for Inheritance
thing and, if they are, be prepared to refactor your existing model, and perhaps Are Not So
even code to reflect whichever approach to storing a person’s name you accept. Obvious
A similar issue can also occur with methods and associations.
224 The Object Primer
DEFINITIONS
Aggregation. The representation of “is part of” associations.
Composition. A strong form of aggregation in which the “whole” is com-
pletely responsible for its parts and each “part” object is only associated with
the one “whole” object.
Figure 6-19.
0..* 1..*
A course is part of a
program
Program 0..* recommended for 0..* Course
One of the following sentences should make sense: “A subclass IS A superclass” TIP
or “A subclass IS LIKE A superclass.” For example, it makes sense to say a
student is a person and a dragon is like a bird. It doesn’t make sense to say a Apply the
student is a vehicle or is like a vehicle, so the class “Student” likely shouldn’t Sentence Rule
inherit from “Vehicle.”
EnrollmentRecord
marksReceived
getAverageToDate()
getFinalMark()
Figure 6-21.
Student 1..* 1..* Seminar An example of an
enrolled in associative class
226 The Object Primer
1. You don’t have to get it perfect at the start. I started the con-
ceptual model by converting my Class Responsibility Collabora-
tor (CRC) model into a UML class model. This was a good start,
but I quickly found I needed to evolve the model as my analysis
of the system moved forward. The point is I didn’t get the model
right at the start and that was okay. I didn’t get the multiplicities
on associations at the beginning, and I didn’t even get all the
classes to start. Many modelers will waste a lot of time at the
beginning of conceptual modeling by focusing on one small
aspect of the model and trying to get it right at first. It’s also
common to see modeling teams argue for hours about whether
to use association, aggregation, or composition in a certain spot
when little difference actually exists among the three options. I
would rather pick one, move forward, and trust that, at some
point in the future, it will become clearer which option to use as
I understand the problem domain better.
2. Start at your domain model. Your CRC model contains impor-
tant information that is relevant to your conceptual model, pro-
viding an excellent starting point.
3. Evolve your class diagram via sequence diagrams. Your sequence
diagrams model the logic of your use cases, in particular, the crit-
ical business logic your system must support. As you develop
your sequence diagrams, the topic of Section 6.2, you quickly
flesh out the behaviors required of your classes.
DEFINITIONS
Postcondition. An expression of the properties of the state of an operation or
use case after it has been invoked successfully.
Precondition. An expression of the constraints under which an operation or use
case will operate properly.
228 The Object Primer
4
I suspect, in future versions of the UML, we will see conditions documented using the
UML constraint notation discussed earlier.
230 The Object Primer
Figure 6-22.
A UML activity
diagram for Enrolling in the
University for the
enrolling in school Fill out Enrollment [incorrect] Obtain Help to Fill first time
for the first time Forms Out Forms
AD #: 007
[correct]
Enroll in University
Attend University
Overview
Presentation
[accepted]
[rejected]
Make Initial Tuition
Enroll In Seminar(s)
Payment
DEFINITIONS
Activity diagram. A UML diagram used to model high-level business
processes or the transitions between states of a class (in this respect, activity dia-
grams are effectively specializations of state chart diagrams).
Data-flow diagram (DFD). A diagram that shows the movement of data
within a system among processes, entities, and data stores. Data-flow diagrams,
also called process diagrams, were a primary artifact of structured/procedural
modeling.
Flow chart. A diagram depicting the logic flow of a single process or method.
Flow charts were a primary artifact of structured/procedural modeling.
State chart diagram. A UML diagram that describes the states an object may
be in, as well as the transitions between states. Formerly referred to as a “state
diagram” or “state-transition diagram.”
TIP Every activity has at least one entry transition—otherwise, you would never
perform the activity, and at least one exit transition—otherwise you would
Activities Have never stop performing it. For each activity, I always ask myself: From where
Entry and Exit could I get into this and where can I go from here? By asking this question, it
Transitions enables you to model the pertinent logic thoroughly.
Figure 6-23.
The iterative steps
of prototyping
Determine Needs
Build Prototype
Evaluate Prototype
[continue]
[finished]
TIP Although UI prototyping is an important part of analysis and design, it’s not
sufficient by itself. UI prototypes depict what will be built, but are unable to
User Interface communicate adequately how they will be used (that is what use case models
Prototyping Is are good for). Furthermore, UI prototypes don’t provide much indication as to
Not a Substitute the details of the business logic behind the screens, which is what sequence and
for Analysis and activity diagrams are good at. And they aren’t good at depicting the static
Design structure of your software, which is where class models excel.
1. Work with the real users. The best people to get involved in
prototyping are the ones who will actually use the application
when it is done. These are the people who have the most to gain
from a successful implementation, and these are the people who
know their own needs best.
2. Use a prototyping tool. Invest the money in a prototyping tool
that enables you to put screens together quickly. Because you
probably won’t want to keep the prototype code you write—
code written quickly is rarely worth keeping—you shouldn’t be
too concerned if your prototyping tool generates a different type
of code than what you intend to develop in.
3. Get your SMEs to work with the prototype. Just as you want to
take a car for a test drive before you buy it, your users should be
DEFINITIONS
WYSIWYG. What You See Is What You Get.
WYSIWYN. What You See Is What You Need.
236 The Object Primer
Figure 6-24.
The Business Entity
analysis pattern
EntityRole
BusinessEntity 1 1..* start
end
DEFINITIONS
Invariant. A set of assertions about an instance or class that must be true at all
“stable” times, where a stable time is the period before a method is invoked on
the object/class and immediately after a method is invoked.
Object Constraint Language (OCL). A formal language, similar to struc-
tured English, to express side-effect-free constraints within UML models.
TIP The real value of analysis patterns is the thinking behind them. A
pattern might not be the total solution to your problem, but it
How to Use Analysis might provide enough insight to help save you several hours or
Patterns Effectively days during development. Consider analysis patterns as a good start
at solutions.
ContactPointType
ContactPoint
1 contacted through 1..* 0..* describes 1..* name
BusinessEntity
{ordered} sendTo() description
asLabel()
Phone
ShippingAddress 0..*
number
call()
sendTo()
asLabel()
ElectronicAddress SurfaceAddress
email street 1 Country
city 0..* name
sendTo() state phoneCode
asLabel() postalCode
sendTo()
asLabel()
Figure 6-25.
consistent manner, it’s that much easier to do technical walk- The Contact Point
throughs that enable you to improve the quality of your devel- analysis pattern
opment efforts.
4. Patterns are potentially better than reusable code. People can
talk about reusable code all they want, but the differences
between system platforms makes this dream difficult at best.
However, patterns support the reuse of other people’s approaches
to solving problems (Ambler, 1998b; Ambler, 1999) and, there-
fore, can be applied in a wide range of environments because
they are not environment-specific.
5. More and more patterns are being developed every day. A lot of
exciting work is going on in patterns, with new patterns being
introduced every day. This enables you to take advantage of the
development efforts of thousands of people, often for the mere cost
of a book, magazine, or telephone call to link you to the Internet.
manual does not fit all. He suggests a tutorial manual for novice users, a The user
user manual for intermediate users, and a reference manual for expert documentation
for your application
users. Tourniaire and Farrell (1997) also recommend that you develop a
includes a tutorial
support user’s guide describing the support services provided to your user
manual, a reference
community, a document that is typically less than a page in length. manual, a user
When appropriate, your user documentation should include a descrip- manual, and a
tion of the skills needed to use your system. For example, your users may support user’s
require training in your business domain or in basic computer skills, such guide.
as using a mouse. This information is needed to develop training plans for
users and by support engineers when they are attempting to determine
the source of a problem. Quite often, support engineers will receive sup-
port calls where the solution is to give the user additional training.
DEFINITIONS
Reference manual. A document, either paper or electronic, aimed at experts
who need quick access to information.
Support user’s guide. A brief document, usually a single page, that describes
the support services for your application that are available to your user commu-
nity. This guide includes support phone numbers, fax numbers, and Web site
locations, as well as hours of operations and tips for obtaining the best services.
Tutorial. A document, either paper or electronic, aimed at novice users who
need to learn the fundamentals of an application.
User manual. A document, either paper or electronic, aimed at intermediate
users who understand the basics of an application, but who may not know how
to perform all applicable work tasks with the application.
244 The Object Primer
processes, processes you should have documented the logic for using a
UML activity diagram. For large systems, you may find you have a section
for each UML package within your use case model or even a separate user
manual. Then, for each use case, add an appropriate subsection describing
it; the use case text will drive the body of that section. You will likely want
to combine steps into paragraphs to make your documentation more read-
able. Wherever you reference a UI element, you may decide to include a
relevant picture of that portion of your user interface (my suggestion is to
wait until you have baselined your user interface design before investing
the time to generate the pictures). You may also decide to replace refer-
ences to business rules with their descriptions to help increase your user’s
understanding of how the system actually works. Although many in the
industry call this a use case driven approach to writing user documenta-
tion, it really is a model-driven approach because your use cases simply
aren’t sufficient for this purpose.
Your use cases, Tutorials are developed in a similar manner to user manuals, although
activity diagrams, a few differences exist. First, tutorials focus on the most critical uses of
and UI prototype the system, whereas a user manual should focus on the entire system.
drive the develop-
Second, tutorials should have a more explicit focus on learning a prod-
ment of your user
manual and
uct, so they’ll include more detailed use instructions than a user manual
tutorial. might. The assumption is that anyone using a tutorial likely knows little
about the system and, therefore, needs more help, whereas someone
using a user manual is probably familiar with the system itself, but needs
help with a specific aspect of it.
Your user interface Your reference manual, because it has a slightly different purpose, is
model often drives generally driven by your user interface model, instead of your use cases
the development of and activity diagrams. I generally include an overview of the system, sec-
your reference
tions for each major portion of your system, and subsections describing
manual.
the major user interface elements. The subsections should describe the
purpose of the relevant screen/report/page and how to work with it.
You will often hear advice within the software industry to write your
documentation before you write you code. Although this is a reasonably
TIP Writing is hard and writing good user documentation is even harder. It takes a
lot of effort and significant skill to do well, the type of skill technical writers
Hire a Technical have. If possible, hire a technical writer to work with you to produce your user
Writer documentation. This will improve the quality of your documentation and,
hence, the quality of your overall user interface, Hiring a technical writer will
also free you to focus on other development activities, such as modeling,
coding, and testing.
Chapter 6 • Determining What to Build: Object-Oriented Analysis 245
good practice, why do people give this advice? I believe the motivation is Model before you
that writing user documentation first forces you to think about how your write your user
documentation
system will be used before you start to build it. My advice is different:
and source code.
invest the time to understand your system by developing requirements for
it, analyzing it, and designing it, and then let this understanding drive the
development of your source code and your user documentation. I have
worked on several systems where we developed the user documentation in
parallel with the source code, not before it, and it worked out well.
Anything you put into a package should make sense when considered with the TIP
rest of the contents of the package. To determine whether a package is
cohesive, a good rule of thumb is you should be able to give your package a Packages
short, descriptive name. If you can’t, then you may have put several unrelated Should Be
things into the package. Cohesive
246 The Object Primer
1. Develop system use cases for the use case diagram of Figure 3-10. Use
the essential use cases you developed for Question 1 in Chapter 3 as
your starting point.
2. Rework the class diagrams of Figures 6-15, 6-16, and 6-18 to include
the fact that professors also enroll in seminars exactly the way stu-
dents do. For the purpose of this question, focus on the associations
DEFINITIONS
Cohesion. The degree of relatedness within an encapsulated unit (such as a
component or a class).
Package. A UML construct that enables you to organize model elements into
groups.
Chapter 6 • Determining What to Build: Object-Oriented Analysis 247
DEFINITION
Baseline. A tested and certified version of a deliverable representing a concep-
tual milestone, which, thereafter, serves as the basis for further development
and that can be modified only through formal change control procedures. A
particular version becomes a baseline when a responsible group decides to des-
ignate it as such.
248 The Object Primer
how? Do you need to verify this change with your SMEs? Why or
why not?
8. Develop sequence diagrams for your use cases in Question 1. As you
develop the sequence diagrams, update your conceptual class model
to reflect new operations or classes you identify. Also, update the
logic of your system use cases as appropriate.
9. Develop a conceptual class model for the bank case study, described
in Section 3.10.1, following the approach described in this chapter.
First, start with your CRC model, and then try to flesh it out as best
you can (develop sequence diagrams for the use cases you developed
in Chapter 3). When you have done so, baseline your model. You
may decide to organize your model using packages, as well as apply
common analysis patterns.
10. Compare and contrast the information content of your domain
model (your CRC model), and your conceptual class model for the
bank case study. What are the strengths and weaknesses of each
model? Why?
11. Compare and contrast the narrative style for writing use cases with
the action-response style. What are the advantages and disadvan-
tages of each? When would or wouldn’t you use each approach?
12. Search the Web for documentation templates for use cases, actors, and
user interface specifications. For use case templates, compare and con-
trast the content they capture with what has been suggested in this
book.
13. Search the Web for papers and information about object-oriented
analysis. Compare and contrast the various techniques. Formulate a
reason why differences exist among the various approaches and dis-
cuss the advantages and disadvantages of having different approaches
available to you.