Unified Modeling Language

advertisement
Unified Modeling Language
Unit 4. Dynamic Modeling
Objectives





Actors & Uses Cases
Sequence Diagram
Dynamic Context Diagram
State Diagram
Activity Diagram
How to make a better dynamic model ?
Phases
1.
Identify all system actors
2.
Draw the static context diagram
3.
Make the uses cases diagram
4.
Describe all the uses cases using an activity
diagram and a sequence diagram
5.
Make state machine diagram
6.
Final : dynamic context diagram
Example : A Public Phone






Call minimal price : 0.1 RON
The user have 2 minutes to compose the destination
phone number after he finished to introduce his
money
The destination phone number may be available or
no
The public phone consume the money for each
minute in which the user speak
The user can introduce money all the times
When the user finish to speak, the public phone
1.Actors & Uses Cases
2.Sequence Diagram
3. Dynamic Context Diagram




The studied system it’s represent by an
object situated on the diagram center
The central object is surrounded by all the
actors
Between each actor and the system is a
linking graphical represented with a line
Over each linking all in-messages and outmessages between the actor and the system
are wrote,without numerotation
Example
unhookReceipter
introMoney(p)
composeNumber(num)
hookReceipter
tonality
Public Phone
linkNumber(num)
finishComunication
Tonality(free)
beginComunication
TU
Dynamic Context Diagram
Caracteristics


This diagram is used as a linking
between the sequnce diagram and the
state machine diagram
To make this diagram is very useful to
create at first for each actor two
messages categories : a category with
all sends messages and other with all
receives messages
4.State Machine Diagram
Generalities
How to find special classes ?
Fundamental concepts
State Machine Organisation
When to use state machine diagram ?
Dynamic Context Diagram & State
Machine Diagram
4.1 Generalities





State Machine are a familiar technique to
describe the behavior of a system
A state machine diagram for a class show the
lifetime behavior of a single object
The static context diagram it isn’t necessary
for all classes of system class diagram
First we must found the classes with a
complex and dynamic behavior
Only for these classes the state machine
diagram is necessary
Generalities …



Each state machine diagram only for
one class
No state machine diagram if the class
haven’t differents states
It is not advised to make a state
machine diagram as a general view for
the sistem
4.2 How to find the special
classes ?



If the objects which instanced a class have
different reaction at the same event
If each reaction type it’s a particullar state
If the class must organize diferent operation
in a fixed order
=> For this class must describe the state
machine diagram
4.3 Fundamental concepts




State
Action & Activity
Event
Transition
4.3.1 State (Definition)
-
Values ensemble which implies the same reponse for
a specific event
Life object period in which the object
It satisfy certains conditions
Wait an event
Make an activity

Special states


-
4.3.2 Action & Activity

Start state action
ex

State activity
ex

initialization procedures (setup,…)
continuous realized (display something …)
Finish state activity
ex
cleaning, exception treatment
State X
Enter / ActionName
Do / ActionName
Exit / ActionName
4.3.3 Event





All extern influence it’s represented by
an event
Time point
Asynchrony
Atomic
Uni-directional
Events may be :









Operation call
Signal eventName(param,param,…)
Parameter nameParam : type
Signal reception
True condition
when(boolean expresion)
Time passage
After ( 5 seconds)
After (10 seconds after exit from the first state)
Events classification



Temporal Event ex after(time)
Intern Event ex when(condition-with-obj-caractersitics)
Reception Message Event
Event description



A class description
With
generalisation
With stereotypes
<<signal>>
Event
<<signal>>
User Event
<<signal>>
<<signal>>
Mouse Click
Key Pressesd
4.3.4 Transition




For connecting only 2 state machine
A transition indicates a movement from
one state to another state
One event can’t activate only one
transition
1 Event
1 Transition
Example
Transition Syntax
Event (args) [guard] / Action (args)
-Boolean expression
-It’s evaluated at event
entrance
-Must be true
-Function
- event parameters
- object attributes values
- object method or a
method of an accessible object
Example 1
Transition Syntax …







All syntax parts are optional
The event can trigger a potential change of state
The guard if it is present is a boolean condition that
must be true for the transition to be taken
The activity it’s some behavior that’s executed during
the transition
A missing guard indicates that you always take the
transition if the event occurs
A missing activity indicates that you do anything
during the transition
A missing event signature it’s rare and you indicated
that you must take the transition immediately
Example 2
4.4 State machine organization
Sequential Substate
Concurent Substate
Superstate

If you find that several state share
common transition and internal
activities it’s useful a superstate
Example of sequential decomposition
& Superstate
Washing
Machine
Description
Example of concurrent decomposition
Concurrent Orthogonal State
H=history pseudostate.This indicates that when the clock is switched on,
the Radio/CD choice goes back to the state the clock was in whet it was
turnned off.
Synchronisation
4.5 When to Use State Machine Diagram




State diagram are good to use at describing
behavior of an object across several uses
cases
State diagram are not very good to describe
behavior that involves a number of objects
collaborating
Use state diagram only for classes that exhibit
an intersting behavior
User Interfaces and controllers have a kind of
behavior that it’s useful to depict with a state
diagram
4.6
Dynamic Context Diagram and State
Machine Diagram


The received messages by an actor
become event which triger a transition
The sended messages by an actor
become action for transition
Our Example
Review
unhookReceipter
tonality
introMoney(p)
composeNumber(num)
hookReceipter
Public Phone
linkNumber(num)
finishComunication
Tonality(free)
beginComunication
TU
Version 1.0
Version 1.1
Version 2.0
Version 2.1
Version 2.2
Give money
UT [insuficient founds] /taxer
introMoney(p) /CreditIcrement(p)
Version 2.3
Give money
UT [insuficient founds] /taxer
introMoney(p) /CreditIcrement(p)
introMoney(p)[p OK] /CreditIcrement(p)
Version 3.0 FiNAL
Give money
UT [insuficient founds] /taxer
5.Activity Diagram




An activity graph is a special form of state
machine intended to model coputational
workflow
An activity graph contains activity states
An activity state represents the execution of a
statement in a procedure or the performance
of an activity in a workflow
An activity diagram is a notation for an
activity diagram
5.1Concepts



-
-
Action
Atomik
It can be interrupt
Activity = Actions Group
May be decomposed in more actions
May be interrupted
Transition
if an activity is finish the workflow going on the next
activity => transition
transitions are also used for exceptions traitement
5.2 Notation
5.3 Example
Thank You !
Download