UML Continued

Download Report

Transcript UML Continued

UML
Part 3
UML2
© Wolfgang Pelz 2000-04
1
Chapter Ten
State Machine Diagrams
UML2
© Wolfgang Pelz 2000-04
2
State Machine Diagrams
• capture the lifecycle and behavior of
objects, subsystems, or systems
• specify the sequence of states an object
goes into, based on responses to events, and
actions the object may perform
UML2
© Wolfgang Pelz 2000-04
3
Terminology
• state - condition or situation in the life of an
object determined by attributes
• transition - movement from one state to
another
• event/trigger - an external stimulus that
may cause a transition
• action - some activity that results in a
change of state or a return value
UML2
© Wolfgang Pelz 2000-04
4
Thanking
Turning a computer on:
states?
transition?
event?
actions?
UML2
© Wolfgang Pelz 2000-04
5
Notation
UML2
© Wolfgang Pelz 2000-04
6
Example State Diagram
Actions: “go up”, “go down”, “arrived”, …
State: “On first floor”, Moving up”, “Idle”, …
UML2
© Wolfgang Pelz 2000-04
7
Messages between State
Diagrams
UML2
© Wolfgang Pelz 2000-04
8
and-substate (concurrency)
UML2
© Wolfgang Pelz 2000-04
9
Sequential Substates
UML2
© Wolfgang Pelz 2000-04
10
Activity Diagram
• captures actions and their results
• variation of state diagram, but emphasizing
actions
• actions: work and activities to be performed
• results: object-state changes (not the major
point)
• actions may be placed in swimlanes
UML2
© Wolfgang Pelz 2000-04
11
Activity Diagram (cont.)
includes:
• how actions are taken
• what they do (activities)
• when they take place (action sequence)
• where they take place (swimlanes)
UML2
© Wolfgang Pelz 2000-04
12
Example of a Printing Program
UML2
© Wolfgang Pelz 2000-04
13
Another way ...
UML2
© Wolfgang Pelz 2000-04
14
Decision Point
UML2
© Wolfgang Pelz 2000-04
15
Forks and Joins
•
•
•
•
concurrent or parallel flow of control
synchronization bar
# of forks matches # of joins
activities in parallel flows may use signals
to communicate (such communicating
sequential processes are called co-routines)
UML2
© Wolfgang Pelz 2000-04
16
Example
UML2
© Wolfgang Pelz 2000-04
17
Swimlanes
(in Activity Diagrams)
• group activities with respect to their
responsibilities
• useful when modeling workflows of
business processes
• specify loci of activities
• every activity belongs to exactly one
swimlane, but transitions may cross lanes
UML2
© Wolfgang Pelz 2000-04
18
Example
UML2
© Wolfgang Pelz 2000-04
19
Use an activity diagram when
• analyzing a use case
• understanding workflow across many use
cases
• multi-threaded applications
• capturing the work to be performed as an
operation is executing
UML2
© Wolfgang Pelz 2000-04
20
Don’t use when...
• trying to see how objects collaborate
(collaborative actions instead of individual
activities); use an interaction diagram
instead
• trying to see how an object behaves over its
lifetime; use a state diagram instead
• modeling a scenario; instead attach it to the
appropriate use case
UML2
© Wolfgang Pelz 2000-04
21