Professional Documents
Culture Documents
Most slides Copyright 2001 © John Wiley & Sons. Others © IBM/Rational.
Slide 1
Objectives
• Understand the rules and style guidelines for
sequence and communication diagrams and
behavioral state machines.
• Understand the processes used to create
sequence and communication diagrams and
behavioral state machines.
• Be able to create sequence and communication
diagrams and behavioral state machines.
• Understand the relationship between the
behavioral models and the structural and
functional models.
Key Ideas
• Behavioral models describe the internal
dynamic aspects of an information system
that supports business processes in an
organization
• Key UML behavioral models are: sequence
diagrams, collaboration diagrams, and
statechart diagrams
CONTEXT: UML DIAGRAMS
The Thirteen (13) UML 2.0 Diagrams
Structural Diagrams
Class
Deployment
Composite Structure
Behavioral Diagrams
Sequence Communication
UML 2.0 Diagrams
CoffeeMachine
MakeCoffee
<<include>>
TeaMaking
FromUser ::Coin ( 10 )
FromUser ::Coffee ()
FillWater ()
WaterOK ()
FillCoffee ()
CoffeeOK ()
HeatWater ()
Warm ()
ToUser :: CupOfCoffee ()
WaterOK
Ctrl
Hw
WaterOK/^FillCoffee;
Hardware Coffee/^HeatWater;
Controller
FillCoffee
WaterForCoffee WaterForCoffee
Class Diagram
Statechart Diagram
FromUser
CustbiCtrl
Architecture Diagram
(Composite Structure)
UML 2.0 Diagrams
Requirements Phase
Analysis Phase
Analysis Phase
• Understand the problem domain
• Create a model describing the problem domain
– Free from any technical or implementation details
– Detailed enough to allow simulation on paper or by using a
modeling tool
• Activities:
– Acquire domain knowledge
– Perform use case analysis
– Define the necessary classes and relationships
– Define the behavior and collaboration between classes
– Test the resulting model
Analysis Phase
Deliverables
• Use Case Model with detailed
use case descriptions
– Natural language
– Sequence diagram
– Activity diagram
– State Machine diagram
• Domain Model
– Class diagram showing domain concepts and
their relationships
Slide 26
Sequence Diagram Syntax
Analysis Phase
Associated
Use Case
Lifeline
Message name
Use Case
Reference
Message line
cific
spe
TAU
The interaction name and page numbering
is Tau specific
Analysis Phase
Lifelines
• A Lifeline consists of a rectangle that identifies the
connectable element (such as a part or component)
and a vertical line indicating its time of existence
Lifeline of Lifeline of an Lifeline of an
unknown Class Anonymous Object of a
Object known class
More Sequence Diagram Syntax
Sample Sequence Diagram
Analysis Phase
Object Communication
• Messages are labeled with the name of the message
(operation or signal) and its argument values.
• Message parameters can be a data type, a variable or a
constant.
• For correctness the variables and constants must be declared
• To make the interaction more general use data types or
variables as parameters
Data type
Variable
Value
Analysis Phase
Referencing
• To avoid unnecessary duplication it is possible to reuse
already existing Sequence Diagrams
• The name is the Use Case name, not the Sequence
Diagram name.
– A Use Case encapsulates zero or more Sequence, or other
types of diagrams
Steps to Build Sequence Diagrams
(Dennis)
1. Set the context
2. Identify which objects will participate
3. Set the lifeline for each object
4. Lay out the messages from top to bottom of the
diagram based on the order in which they are sent
5. Add execution occurrence to each object‘s lifeline
6. Validate the sequence diagram
Analysis Phase
Communication Diagrams
Example: Communication Diagram
5: display course offerings( )
6: display blank schedule( )
: Student
2: get course offerings( )
4: get course offerings( )
: RegistrationController : CourseCatalogSystem
Communication Diagrams Contents:
Objects
: RegisterForCoursesForm
Objects
Actors
: Student
2: get course offerings( )
4: get course offerings( )
: RegistrationController : CourseCatalogSystem
Sequence and Communication
Diagram Similarities
• Semantically equivalent
– Can convert one diagram to the other without
losing any information
• Model the dynamic aspects of a system
• Model a use-case scenario
Sequence and Communication
Diagram Differences
Sequence Communication
diagrams diagrams
Show the explicit Show relationships in
sequence of messages addition to interactions
Show execution Better for visualizing
occurrence patterns of
Better for visualizing communication
overall flow Better for visualizing all
Better for real-time of the effects on a given
specifications and for object
complex scenarios Easier to use for
brainstorming sessions
ACTIVITY DIAGRAMS
Analysis Phase
Activity Diagrams
• Activity diagrams describe the workflow behavior
of a system
• Activity diagrams can show activities that are
conditional or parallel.
• Activity Diagrams are useful for:
– analyzing a use case by describing what actions need
to take place and when they should occur
– describing a complicated sequential algorithm
– modeling applications with parallel processes
– modeling bussiness workflow
Analysis Phase
Action Node
Fork Join
Activity Final
Decision Node
Guard
Analysis Phase
Action/Activity
An action is an executable unit. Can also refer to a new
activity diagram.
Analysis Phase
Fork/Join symbol
Divides a flow into multiple concurrent flows. Flows can
be split and synchronized again.
Analysis Phase
Text symbol
// Comment symbol:
• unconnected or unselected it looks almost like a text symbol.
Analysis Phase
[Display("Insert Card")]
to another
'Customer Inserts Card'
Card
[Display("Enter Pin")]
ValidateCardandPin
CardInfo
ValidateCardInfo
Analysis Phase
Activity Diagram – Example
Card Inserted
System prompts
for PIN
[NbrOfAttempts < 3]
Prompt
PIN invalid
[Foreign currency
[Withdrawal] transaction]
Reject card
Customer enters Customer
amount enters currency
Analysis Phase
• Events
change the values of the object’s attributes
• Transitions
movement of an object from one state to another
• Actions
atomic, non-decomposable processes
• Activities
non-atomic, decomposable processes
State Machine Syntax
Analysis Phase
Transition
Self
transition
State
Final
state
Sample State Machine
Analysis Phase
Transition (1)
event-name ( parameter-list ) [ guard-condition] / action-expression;
Event-name Parameter-list
cific
U spe
TA
The action
Action-expression language in
transitions is
Tau specific
Guard-condition
Analysis Phase
Transition (2)
event-name ( parameter-list ) [ guard-condition] / action-expression;
incoming-signal-name / signal-output;
Warm / ^FillWater;
incoming-signal-name ( parameter-list ) /
operation-call;
Coin(faceValue) / Amount = AddCoin ( Amount ,
faceValue );
The variable that will contain the parameter
value, must be declared and visible within the
scope of the state machine
Analysis Phase
Transition (3)
event-name ( parameter-list ) [ guard-condition] / action-expression;
[ guard-condition] / signal-output
( parameters-list );
[Amount >= drinkCost] /
^theMessage(“Please make your drink selection”);
incoming-signal-name [guard-condition] /
signal-output;
Tea [Amount < drinkCost] / ^GetTeaBag;
Steps to Build a State Machine
1. Set the context
2. Identify the initial, final, and stable states of
the object
3. Determine the order in which the object will
pass through the stable states
4. Identify the events, actions, and guard
conditions associated with the transitions
5. Validate the behavioral state machine
Analysis Phase