You are on page 1of 6

10

State Transition Diagram


State Transition Diagram

0
0
0
Lab 10: Modeling of Objects states using state diagram

Objectives

 Deeper understanding of UML state transition diagrams (STD).

1. Outline
 UML state diagrams.
 UML state diagram notation
 UML state details
 Examples

2. Background
Mainly, we use interaction diagrams to study and model the behavior of
objects in our system. Sometimes, we need to study the behavior of a
specific object that shows complex behavior to better understand its
dynamics. For that sake, UML provides state transition diagrams used to
model the behavior of objects of complex behavior. In this Lab, UML
state transition diagrams will be introduced. We will study their notation
and how can we model them using Rational Rose.
2.1 UML State Diagrams
State diagrams show how one specific object changes state as it
receives and processes messages:
 A State transition diagram shows the lifecycle of an object
 A state is a condition of an object for a particular time
 An event causes a transition from one state to another state
 Here is a State chart for a Phone Line object:
States in rectangle with rounded corners, Transitions as
arrows

 Transitions labels have three optional parts:


Event [Guard] / Action
 Find one of each
 Item Received is an event, /get first item is an action, [Not all items
checked] is a guard
 State may also label activities, e.g., do/check item

Superstates (nested states)


 Example shows a super-state of three states
 When one state is complex, you can include sub-states in it.
 drawn as nested rounded rectangles within the larger state
Concurrency in state diagrams
 Dashed line indicates that an order is in two different states, e.g.
Checking & Authorizing
 When order leaves concurrent states, it’s in a single state: Canceled,
Delivered or Rejected

2.2 Creating State Transition Diagrams


 States are represented by rectangles with rounded corners with an attribute
name with a values associated with it.
 The name of the state is placed within the box.
 Events are shown by arrows.
 An event occurs when at an instant in time when a value is changed.
 A message is data passed from one object to another.
 The name of a state usually refers to the name of the attribute and the values
associated to it.
 Example, a student object may receive a message to change its name. The
state of that object changes from the first name state to the new state name.
 The name of the state is placed in the top compartment.
 State variables are placed in the next compartment.
 The operations associated with the state are listed in the lowest compartment
of the state box.

 In the operations part, we usually use one of the following reserved words:
o Entry: a specific action performed on the entry to the state.
o Do: an ongoing action performed while in the state.
o On: a specific action performed while in the state.
o Exit: a specific action performed on exiting the state.
 There are two special states added to the state transition diagram- start state
and end state.
 Notation of start state is a solid black circle and for the end state a bull’s eye is
used.

3. CASE Tools
Visual Paradigm, Rational Rose, Star UML etc.

4. In-Class Example
Now you will learn how to apply the above mentioned methods of
drawing state transition diagrams (STD).

 State Diagram for Seminar Registration


5. Exercises

Lab Task 1
Draw a state diagram for a claim

A third party claim arises from an incident that has occurred. The claim must be
reported to the claims office within the statutory period to be valid. When the
claim is reported, the incident is preferably verified by a member of staff who was
present at the time. The claim is recorded and evaluated. If it is a trivial claim,
the claims assessor checks the claimant for previous claims and, if there are no or
1 previous claims then a payment is made and the claim is settled. If there are
previous claims, the claimant will be referred to the courts. More serious claims
may await expert evidence and several different court hearings. At any stage, the
claim may be dropped, or a payment made without admitting liability. If the
claimant is a minor, the claim must remain on the books until the claimant is over
21. If a claim is settled by a court, it may be appealed. During this time, the
claim remains open.

Lab Task 2
OTOS’s pharmacy is the distributer of various pharmaceuticals products. They
have a huge network of customers. The registered customers can only book orders
for the specified product. If the specified product s available the required quantity
is checked against the quantity on hand (QOH). If the required quantity is less
than QOH a deliver challan is prepared. After the delivery of the product an
Invoice is prepared by accountant who contains the cost of ordered items,
deductions if any (in case of damaged or lost goods) and previous outstanding
balance. Then the invoice is sent to the customer. Draw state diagram.

6. Deliverables
You should use these techniques to create state transition diagrams for above
tasks.

You might also like