You are on page 1of 9

Lecture-10: OOAD – UML Behavioral Diagrams

1. State-Chart Diagram
A state–chart diagram shows a state machine that depicts the control flow of an object from one
state to another. A state machine portrays the sequences of states which an object undergoes
due to events and their responses to events. State-chart diagrams are used for modeling objects
which are reactive in nature.
State–Chart Diagrams comprise of States, Transitions, Events and Actions

 Components
o States: a condition of an object
o Events: a state changing occurrence
o Transitions: from one state to the next, occur when the associated event occurs
How to Draw a State Diagram
i. Before you begin your drawing find the initial and final state of the object in question.
ii.Next, think of the states the object might undergo. For example, in e-commerce a product will
have a release or available date, a sold out state, a restocked state, placed in cart state, a
saved on wish list state, a purchased state, and so on.
Certain transitions will not be applicable when an object is in a particular state, for example a
product can be in a purchased state or a saved in cart state if its previous state is sold out.
Basic State Chart Diagram Symbols and Notations
States
States represent situations during the life of an object.
You can easily illustrate a state by using a rectangle
with rounded corners.

Transition
A solid arrow represents the path between different states of an object. Label the transition with
the event that triggered it and the action that results from it. A state can have a transition that
points back to itself.
Initial State
A filled circle followed by an arrow represents the object's initial state.

Final State
An arrow pointing to a filled circle nested inside another circle represents the object's final state.
Sample State Diagram: Without Starting and ending nodes

ClassTime
Breakfast InClass
Alarm

NextClassStartTime
Sleeping
ClassOver
DinnerFinished

DinnerTime
Dinner Studying

Augmented Diagrams
• Constraints/guards needed for better model
– Condition(s) added to transition(s)
– If event occurs, transition takes place only if condition is satisfied
• Actions can be added to transitions
– Performed if transition takes place
• Actions on state entry and state exit also

Student Example 2

BreakfastOver
Breakfast Studying

Alarm

DinnerTime [NoMoreClasses] ClassTime

Sleeping
ClassOver [<DinnerTime or
More Classes]
DinnerFinished

ClassOver [>=DinnerTime &


Dinner NoMoreClasses] InClass

State Model Representations


• Graphical: useful for small systems
• Tables
– State/state or event/state
– Better for larger models
– Duplicate events and states are obvious
– Easier to build up incrementally
• State variable modification equations
State/State Model Table

Event/State Model Table


Example:

Example:
In the Automated Trading House System, let us model Order as an object and trace its
sequence. The following figure shows the corresponding state–chart diagram.
2. Activity Diagrams
An activity diagram depicts the flow of activities which are ongoing non-atomic operations in a
state machine. Activities result in actions which are atomic operations.
Activity diagrams comprise of:
– Activity states and action states
– Transitions
– Objects
Activity diagrams are used for modeling:
– workflows as viewed by actors, interacting with the system.
– details of operations or computations using flowcharts.

Basic Activity Diagram Notations and Symbols


Initial State or Start Point
A small filled circle followed by an arrow represents the initial action state or the start point for
any activity diagram. For activity diagram using swim lanes, make sure the start point is placed
in the top left corner of the first column.

Activity or Action State


An action state represents the non-interruptible action of objects. You can draw an action state
by using a rectangle with rounded corners.

Action Flow
Action flows, also called edges and paths, illustrate the transitions from one action state to
another. They are usually drawn with an arrowed line.
Object Flow
Object flow refers to the creation and modification of objects by
activities. An object flow arrow from an action to an object means
that the action creates or influences the object. An object flow arrow
from an object to an action indicates that the action state uses the
object.

Decisions and Branching


A diamond represents a decision with alternate paths. When an
activity requires a decision prior to moving on to the next activity,
add a diamond between the two activities. The outgoing alternates
should be labeled with a condition or guard expression.
Guards
In UML, guards are a statement written next to a decision diamond that must be true before
moving next to the next activity. These are not essential but are useful.
Note symbol:
Allows the diagram creators or collaborators to communicate additional messages that don't fit
within the diagram itself. Leave notes for added clarity and specification.
Send signal symbol
Indicates that a signal is being sent to a receiving activity.
Receive signal symbol
Demonstrates the acceptance of an event. After the event is received, the flow that comes from
this action is completed.
Sent and Received Signals
Signals represent how activities can be modified from outside the system. They usually appear in
pairs of sent and received signals, because the state can't change until a response is received,
much like synchronous messages in a sequence diagram. For example, an authorization of
payment is needed before an order can be completed.

Fork symbol
Splits a single activity flow into two concurrent activities. Symbolized with multiple
arrowed lines from a join.
Joint symbol/ Synchronization bar
Combines two concurrent activities and re-introduces them to a flow where only one activity
occurs at a time. Represented with a thick vertical or horizontal line.
Synchronization
A fork and join mode used together are often referred to as synchronization.

Time Event
This refers to an event that stops the flow for a time;
an hourglass depicts it.

Merge Event
A merge event brings together multiple flows that are not
concurrent.
Swim lanes
Swim lanes group related activities
into one column.

Option loop symbol


Allows the creator to model a
repetitive sequence within the
option loop symbol.

Flow final symbol


Represents the end of a specific
process flow. This symbol
shouldn’t represent the end of all
flows in an activity; in that
instance, you would use the end
symbol. The flow final symbol
should be placed at the end of a
process in a single activity flow.

Final State or End Point


An arrow pointing to a filled circle nested inside another circle represents the final action state.
Example: Many of the activities
people want to accomplish
online, checking email, managing
finances, ordering clothes, etc.
require them to log into a
website. This activity diagram
shows the process of logging into
a website, from entering a
username and password to
successfully logging

Example: Activity diagram for a


banking system
This diagram shows the process of
either withdrawing money from or
depositing money into a bank account.
An advantage of representing the
workflow visually in UML is the ability
to show withdrawals and deposits on
one chart. in to the system.
Example: The following figure shows an activity diagram of a portion of the Automated Trading
House System.

You might also like