0% found this document useful (0 votes)
9 views19 pages

UML State Machine Diagram Guide

The document discusses UML state machine diagrams, which illustrate the events, states, and transitions of an object, showing its behavior in response to events. It outlines guidelines for applying state machine diagrams to state-dependent objects, emphasizing their use in modeling complex reactive objects and legal sequences of operations. Examples include physical devices, business transactions, and communication protocols, highlighting the importance of understanding state changes and event responses.

Uploaded by

Karthick M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views19 pages

UML State Machine Diagram Guide

The document discusses UML state machine diagrams, which illustrate the events, states, and transitions of an object, showing its behavior in response to events. It outlines guidelines for applying state machine diagrams to state-dependent objects, emphasizing their use in modeling complex reactive objects and legal sequences of operations. Examples include physical devices, business transactions, and communication protocols, highlighting the importance of understanding state changes and event responses.

Uploaded by

Karthick M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

UNIT III - DYNAMIC AND

IMPLEMENTATION UML DIAGRAMS

[Link]
Assistant Professor
Department of Computer Science and Engineering
STATE MACHINE DIAGRAM

2
STATE MACHINE DIAGRAM

• A UML state machine diagram illustrates the interesting events and states of an
object, and the behavior of an object in reaction to an event.

• Transitions are shown as arrows, labelled with their event.

• States are shown in rounded rectangles.

• It is common to include an initial pseudo-state, which automatically transitions to


another state when the instance is created.

• The State chart diagram shows the life cycle of the object. Sometimes it is not
possible to show each & every event in the state diagram.
STATE MACHINE DIAGRAM
STATE MACHINE DIAGRAM
Events, States, and Transitions
Events
An event is a significant or noteworthy occurrence. Eg: A telephone receiver is taken
off the hook.
States
A state is the condition of an object at a moment in time the time between events.
Eg: A telephone is in the state of being "idle" after the receiver is placed on the hook
and until it is taken off the hook.
Transitions
A transition is a relationship between two states that indicates that when an event
occurs, the object moves from the prior state to the subsequent state. Eg: When the
event "off hook" occurs, transition the telephone from the "idle" to "active" state.
STATE MACHINE DIAGRAM
Guidelines: To Apply State Machine Diagrams

Object can be classified into

1) State-Independent Object: If an object always responds the same way to an event,


then it is considered state-independent.

2) State-Dependent Objects: State-dependent objects react differently to events


depending on their state or mode.
STATE MACHINE DIAGRAM
Guidelines: Consider state machines for state-dependent objects with complex

behavior, not for state-independent objects

Example:

A telephone is very state-dependent. The phone's reaction to pushing a particular


button (generating an event) depends on the current mode of the phone-off hook,
engaged, in a configuration subsystem, and so forth.
STATE MACHINE DIAGRAM
Modeling State-Dependent Objects:

State machines are applied in two ways:

1. To model the behavior of a complex reactive object in response to events.

2. To model legal sequences of operations protocol or language specifications.


STATE MACHINE DIAGRAM
1. Complex Reactive Objects
a) Physical Devices controlled by software
Phone, car, microwave oven: They have complex and rich reactions to events, and
the reaction depends upon their current mode.
b) Transactions and related Business Objects
How does a business object (a sale, order, payment) react to an event?
Example: What should happen to an Order if a cancel event occurs? And
understanding all the events and states that a Package can go through in the
shipping business can help with design, validation, and process improvement.
c) Role Mutators: These are objects that change their role.
A Person changing roles from being a civilian to a veteran. Each role is represented
by a state.
STATE MACHINE DIAGRAM
Example 1: Physical Devices / Nested States – Telephone Object
• A state allows nesting to contain substates
• A substate inherits the transitions of its superstate (the enclosing state).
• It may be graphically shown by nesting them in a superstate box.
Example:
When a transition to the Active state occurs, creation and transition into the
PlayingDialTone substate occurs. No matter what substate the object is in, if the on
hook event related to the Active superstate occurs, a transition to the Idle state
occurs.
STATE MACHINE DIAGRAM

Example 1: Physical Devices / Nested States – Telephone Object


STATE MACHINE DIAGRAM
Example 2: Transactions and related Business Objects

Order Processing System – Order Object


STATE MACHINE DIAGRAM
2. Protocols and Legal Sequences

a) Communication Protocols: TCP and new protocols, can be easily and clearly
understood with a state machine diagram.

Example: A TCP "close" request should be ignored if the protocol handler is


already in the "closed" state.
STATE MACHINE DIAGRAM
b) UI Page/Window Flow or Navigation: When doing UI modeling, it can be useful to
understand the legal sequence between Web pages or windows;

State Machine Diagram - Web Page Navigation Modeling


STATE MACHINE DIAGRAM
c) UI Flow Controllers or Sessions: These are usually server-side objects
representing an ongoing session or conversations with a client.

Example:

A Web application that remembers the state of the session with a Web client and
controls the transitions to new Web pages, or the modified display of the current
Web page, based upon the state of the session and the next operation that is
received.
STATE MACHINE DIAGRAM
d) Use Case System Operations: The system operations for Process Sale:
makeNewSale, enterItem etc. These should arrive in a legal order. Example:
endSale should only come after one or more enterItem operations.
STATE DIAGRAM: COFFEE VENDING MACHINE
STATE MACHINE DIAGRAM
When to Use State Diagram ?

• To model the object states of a system.

• To model lifetime of an object from creation to termination.

• To model the reactive system.

• To identify the events responsible for state changes.

• Forward and reverse engineering.

You might also like