Terms and Concepts
A use case is a description of a set of sequences of actions, including variants, that a system performs to yield an observable result of value to an actor. Graphically, a use case is rendered as an ellipse.
The notation for use cases is similar to that for collaborations, as discussed in Chapter 28 . |
Subject
The subject is a class described by a set of use cases. Usually the class is a system or subsystem. The use cases represent aspects of the behavior of the class. The actors represent aspects of other classes that interact with the subject. Taken together, the use cases describe the complete behavior of the subject.
Names
Every use case must have a name that distinguishes it from other use cases. A name is a textual string. That name alone is known as a simple name ; a qualified name is the use case name prefixed by the name of the package in which that use case lives. A use case is typically drawn showing only its name, as in Figure 17-2.
Figure 17-2. Simple and Qualified Names

A use case name must be unique within its enclosing package, as discussed in Chapter 12 . |
Use Cases and Actors
An actor represents a coherent set of roles that users of use cases play when interacting with these use cases. Typically, an actor represents a role that a human, a hardware device, or even another system plays with a system. For example, if you work for a bank, you might be a LoanOfficer. If you do your personal banking there, as well, you'll also play the role of Customer. An instance of an actor, therefore, represents an individual interacting with the system in a specific way. Although you'll use actors in your models, actors are not actually part of the software application. They live outside the application within the surrounding environment.In an executing system, actors need not exist as separate entities. One object may play the part of multiple actors. For example, one Person may be both a LoanOfficer and a Customer. An actor represents one aspect of an object.As Figure 17-3 indicates, actors are rendered as stick figures. You can define general kinds of actors (such as Customer) and specialize them (such as CommercialCustomer) using generalization relationships.
Figure 17-3. Actors

Generalization is discussed in Chapters 5 and 10 . |
Stereotypes are discussed in Chapter 6 . |
Association relationships are discussed in Chapters 5 and 10; messages are discussed in Chapter 16 . |
Use Cases and Flow of Events
A use case describes what a system (or a subsystem, class, or interface) does but it does not specify how it does it. When you model, it's important that you keep clear the separation of concerns between this outside and inside view.You can specify the behavior of a use case by describing a flow of events in text clearly enough for an outsider to understand it easily. When you write this flow of events, you should include how and when the use case starts and ends, when the use case interacts with the actors and what objects are exchanged, and the basic flow and alternative flows of the behavior.For example, in the context of an ATM system, you might describe the use case ValidateUser in the following way:
Main flow of events :
The use case starts when the system prompts the Customer for a PIN number. The Customer can now enter a PIN number via the keypad. The Customer commits the entry by pressing the Enter button. The system then checks this PIN number to see if it is valid. If the PIN number is valid, the system acknowledges the entry, thus ending the use case.Exceptional flow of events :
The Customer can cancel a transaction at any time by pressing the Cancel button, thus restarting the use case. No changes are made to the Customer 's account.Exceptional flow of events :
The Customer can clear a PIN number anytime before committing it and reenter a new PIN number.Exceptional flow of events :
If the Customer enters an invalid PIN number, the use case restarts. If this happens three times in a row, the system cancels the entire transaction, preventing the Customer from interacting with the ATM for 60 seconds.
NoteYou can specify a use case's flow of events in a number of ways, including informal structured text (as in the example above), formal structured text (with pre- and postconditions), state machines (particularly for reactive systems), activity diagrams (particularly for workflows), and pseudocode.
Use Cases and Scenarios
Typically, you'll first describe the flow of events for a use case in text. As you refine your understanding of your system's requirements, however, you'll want to also use interaction diagrams to specify these flows graphically. Typically, you'll use one sequence diagram to specify a use case's main flow, and variations of that diagram to specify a use case's exceptional flows.
Interaction diagrams, including sequence diagrams and collaboration diagrams, are discussed in Chapter 19 . |
Instances are discussed in Chapter 13 . |
Use Cases and Collaborations
A use case captures the intended behavior of the system (or subsystem, class, or interface) you are developing, without having to specify how that behavior is implemented. That's an important separation because the analysis of a system (which specifies behavior) should, as much as possible, not be influenced by implementation issues (which specify how that behavior is to be carried out). Ultimately, however, you have to implement your use cases, and you do so by creating a society of classes and other elements that work together to implement the behavior of this use case. This society of elements, including both its static and dynamic structure, is modeled in the UML as a collaboration.
Collaborations are discussed in Chapter 28 . |
Figure 17-4. Use Cases and Collaborations

Realization is discussed in Chapters 9 and 10 . |
Architecture is discussed in Chapter 2 . |
Organizing Use Cases
You can organize use cases by grouping them in packages in the same manner in which you can organize classes.
Packages are discussed in Chapter 12 . |
Figure 17-5. Generalization, Include, and Extend

Generalization is discussed in Chapters 5 and 10 . |
Dependency relationships are discussed in Chapters 5 and 10; stereotypes are discussed in Chapter 6 . |
NoteThere is no predefined UML notation for expressing use case scenarios. The syntax used here is a kind of structured natural language. Several authors have suggested that an informal notation is best, because use cases should not be regarded as rigid specifications that generate code automatically; others have proposed formal notations.An extend relationship between use cases means that the base use case implicitly incorporates the behavior of another use case at a location specified indirectly by the extending use case. The base use case may stand alone, but under certain conditions its behavior may be extended by the behavior of another use case. This base use case may be extended only at certain points called, not surprisingly, its extension points. You can think of extend as the extension use case pushing behavior to the base use case.You use an extend relationship to model the part of a use case the user may see as optional system behavior. In this way, you separate optional behavior from mandatory behavior. You may also use an extend relationship to model a separate subflow that is executed only under given conditions. Finally, you may use an extend relationship to model several flows that may be inserted at a certain point, governed by explicit interaction with an actor. You may also use an extend relationship to distinguish configurable parts of an implementable system; the implication is that the system can exist with or without the various extensions.You render an extend relationship as a dependency, stereotyped as extend. You may list the extension points of the base use case in an extra compartment. These extension points are just labels that may appear in the flow of the base use case. For example, the flow for Place order might read as follows:
Track order:
obtain and verify the order number;
include 'Validate user';
for each part in the order,
query the order status;
report overall status to user.
Place order:
include 'Validate user';
collect the user's order items;
set priority: extension point;
submit the order for processing.
Dependency relationships are discussed in Chapters 5 and 10; stereotypes and extra compartments are discussed in Chapter 6 . |
Other Features
Use cases are classifiers, so they may have attributes and operations that you may render just as for classes. You can think of these attributes as the objects inside the use case that you need to describe its outside behavior. Similarly, you can think of these operations as the actions of the system you need to describe a flow of events. These objects and operations may be used in your interaction diagrams to specify the behavior of the use case.
Attributes and operations are discussed in Chapter 4; state machines are discussed in Chapter 22 . |