0% found this document useful (0 votes)
5 views

ooad5

UML state machine diagrams illustrate the states of an object and the transitions between those states, utilizing various notations such as rounded rectangles for states and arrows for transitions. Key concepts include events, triggers, guards, effects, and special constructs like super-states, entry/exit points, choice and junction pseudo-states, and concurrent regions. These diagrams are essential for modeling dynamic behavior in systems, providing a clear representation of how objects interact and change states over time.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

ooad5

UML state machine diagrams illustrate the states of an object and the transitions between those states, utilizing various notations such as rounded rectangles for states and arrows for transitions. Key concepts include events, triggers, guards, effects, and special constructs like super-states, entry/exit points, choice and junction pseudo-states, and concurrent regions. These diagrams are essential for modeling dynamic behavior in systems, providing a clear representation of how objects interact and change states over time.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

UML 2 State Machine Diagrams

State Machine Diagrams


• UML state machine diagrams depict the various states that an
object may be in and the transitions between those states.
• In other modeling languages, it is common for this type of a
diagram to be called a state-transition diagram or even simply a
state diagram.
State Machine Diagrams
• States - A state is denoted by a round-cornered rectangle
with the name of the state written inside it.

• Initial and Final States - The initial state is denoted by a filled


black circle and may be labeled with a name. The final state is
denoted by a circle with a dot inside and may also be labeled
with a name.
Event
• An event is an instant in time that may be significant to the
behavior of the objects in a class
– Events can have associated arguments
• Events tend to represent
– Commands or requests from other objects - Significant times (it’s time
to...)
– Circumstances or happenings in other objects (the temperature
monitor notices the temperature rising over a safety setpoint)
– “Custodial” (creation, deletion, simple update)
• Notation
– Events are written simply as text strings
Open
Deposit(Amount)
Withdraw(Amount)
Close
Transition
• A transition shows a valid progression in state
– Simply, “if you were in this state and you saw this event, that’s the
state you would end up in”

• Examples
– If a Bank Account was Closed and it saw an Open event, it would end
up in the Opened state
– If the account was Opened and it saw a Close event it would end up in
the Closed state

• Notation
State Machine Diagrams
• Transitions - Transitions is a progression from one state to another are
denoted by lines with arrowheads. A transition may have a trigger, a guard
and an effect.
• Self-Transitions - A state can have a transition that returns to itself, as in
the following diagram. This is most useful when an effect is associated
with the transition.

• "Trigger" is the cause of the transition, which could be a signal, an event, a


change in some condition, or the passage of time. "Guard" is a condition
which must be true in order for the trigger to cause the transition. "Effect"
is an action which will be invoked directly on the object that owns the
state machine as a result of the transition.
an example of a state diagram might look like for an Order object. When
the object enters the Checking state it performs the activity "check
items.“ After the activity is completed the object transitions to the next
state based on the conditions [all items available] or [an item is not
available]. If an item is not available the order is canceled. If all items
are available then the order is dispatched. When the object transitions to
the Dispatching state the activity "initiate delivery" is performed. After
this activity is complete the object transitions again to the Delivered
state.
State transition

❑ Event: comes from outside the object modeled


❑ Message: generates event for another object
❑ Guard: outcome of internal object computation
Super state
• A super-state is used when many transitions
lead to the a certain state. Instead of showing
all of the transitions from each state to the
redundant state a super-state can be used to
show that all of the states inside of the
super-state can transition to the redundant
state.
• This helps make the state diagram easier to
read.
Super state
State Machine Diagrams
• Entry Point - Sometimes you won’t want to enter a sub-machine at
the normal initial state. For example, in the following sub-machine
it would be normal to begin in the "Initializing" state, but if for
some reason it wasn’t necessary to perform the initialization, it
would be possible to begin in the "Ready" state by transitioning to
the named entry point.
State Machine Diagrams
• Exit Point - In a similar manner to entry points, it is possible to
have named alternative exit points. The following diagram
gives an example where the state executed after the main
processing state depends on which route is used to transition
out of the state.
State Machine Diagrams
• Choice Pseudo-State - A choice pseudo-state is shown as a diamond with
one transition arriving and two or more transitions leaving. The following
diagram shows that whichever state is arrived at, after the choice
pseudo-state, is dependent on the message format selected during
execution of the previous state.
State Machine Diagrams
• Junction Pseudo-State - Junction pseudo-states are used to chain together
multiple transitions. A single junction can have one or more incoming, and one
or more outgoing, transitions; a guard can be applied to each transition.
Junctions are semantic-free. A junction which splits an incoming transition into
multiple outgoing transitions realizes a static conditional branch, as opposed
to a choice pseudo-state which realizes a dynamic conditional branch.
State Machine Diagrams
• Concurrent Regions - A state may be divided into regions containing
sub-states that exist and execute concurrently. The example below shows
that within the state "Applying Brakes", the front and rear brakes will be
operating simultaneously and independently. Notice the use of fork and
join pseudo-states, rather than choice and merge pseudo-states. These
symbols are used to synchronize the concurrent threads.
State concurrency
State diagram of ticket machine

You might also like