0% found this document useful (0 votes)
196 views31 pages

State Diagram Activity Diagram

The document discusses state machine diagrams and activity diagrams. State machine diagrams can be used to describe the different states an object passes through in response to events, and include states, transitions between states triggered by events, and actions. Activity diagrams show the flow of activities and their coordination, and can model business workflows and complex operations.
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)
196 views31 pages

State Diagram Activity Diagram

The document discusses state machine diagrams and activity diagrams. State machine diagrams can be used to describe the different states an object passes through in response to events, and include states, transitions between states triggered by events, and actions. Activity diagrams show the flow of activities and their coordination, and can model business workflows and complex operations.
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/ 31

6.

State Diagram
Activity Diagram
Objects

• Process View
 State Machine Diagram
 Activity Diagram

Analysis and Design of IS 2


State Diagram

• The behavior of an entity is not only a direct


consequence of its inputs, but it also
depends on its preceding state.
• State machine diagram typically are used to
describe state-dependent behavior for an
object.
• An object responds differently to the same
event depending on what state it is in.

Analysis and Design of IS 3


• State machine diagrams are usually applied
to objects but can be applied to any element
that has behavior to other entities such as:
actors, use cases, methods, subsystems
systems and etc. and they are typically used
in conjunction with interaction diagrams
(usually sequence diagrams).

Analysis and Design of IS 4


What is a State?

• Rumbaugh defines that:


 "A state is an abstraction of the attribute values
and links of an object. Sets of values are grouped
together into a state according to properties that
affect the gross behavior of the object.“
• State Notation

Analysis and Design of IS 5


Characteristics of State Machine Notations

• A state occupies an interval of time.


• A state is often associated with an
abstraction of attribute values of an entity
satisfying some condition(s).
• An entity changes its state not only as a
direct consequence of the current input, but it
is also dependent on some past history of its
inputs.

Analysis and Design of IS 6


State

• A state is a constraint or a situation in the life


cycle of an object, in which a constraint
holds, the object executes an activity or waits
for an event.
• A state machine diagram is a graph
consisting of:
 States (simple states or composite states)
 State transitions connecting the states

Analysis and Design of IS 7


• Characteristics of State
 State represent the conditions of objects at certain
points in time.
 Objects (or Systems) can be viewed as moving
from state to state
 A point in the lifecycle of a model element that
satisfies some condition, where some particular
action is being performed or where some event is
waited

Analysis and Design of IS 8


• Initial and Final States
 The initial state of a state machine diagram, known as an
initial pseudo-state, is indicated with a solid circle. A
transition from this state will show the first real state
 The final state of a state machine diagram is shown as
concentric circles. An open loop state machine represents
an object that may terminate before the system terminates,
while a closed loop state machine diagram does not have a
final state; if it is the case, then the object lives until the
entire system terminates.

Analysis and Design of IS 9


Events

• An event signature is described as Event-name


(comma-separated-parameter-list). Events
appear in the internal transition compartment of
a state or on a transition between states. An
event may be one of four types:
 Signal event - corresponding to the arrival of an
asynchronous message or signal
 Call event - corresponding to the arrival of a
procedural call to an operation
 Time event - a time event occurs after a specified time
has elapsed
 Change event - a change event occurs whenever a
specified condition is met

Analysis and Design of IS 10


• Characteristics of Events
 Represents incidents that cause objects to
transition from one state to another.
 Internal or External Events trigger some activity
that changes the state of the system and of some
of its parts
 Events pass information, which is elaborated by
Objects operations. Objects realize Events
 Design involves examining events in a state
machine diagram and considering how those
events will be supported by system objects

Analysis and Design of IS 11


Transition

• Transition lines depict the movement from one state to another. Each
transition line is labeled with the event that causes the transition.
 Viewing a system as a set of states and transitions between states is very useful
for describing complex behaviors
 Understanding state transitions is part of system analysis and design
 A Transition is the movement from one state to another state
 Transitions between states occur as follows:
 An element is in a source state
 An event occurs
 An action is performed
 The element enters a target state

• Multiple transitions occur either when different events result in a state


terminating or when there are guard conditions on the transitions
• A transition without an event and action is known as automatic
transitions

Analysis and Design of IS 12


Actions - Activity

• Actions
 Action is an executable atomic computation, which includes
operation calls, the creation or destruction of another object,
or the sending of a signal to an object. An action is
associated with transitions and during which an action is not
interruptible - e.g., entry, exit

• Activity
 Activity is associated with states, which is a non-atomic or
ongoing computation. Activity may run to completion or
continue indefinitely. An Activity will be terminated by an
event that causes a transition from the state in which the
activity is defined

Analysis and Design of IS 13


• Characteristics of Action and Activities
 States can trigger actions
 States can have a second compartment that contains actions
or activities performed while an entity is in a given state
 An action is an atomic execution and therefore completes
without interruption
 Five triggers for actions: On Entry, Do, On Event, On Exit, and
Include
 An activity captures complex behavior that may run for a long
duration - An activity may be interrupted by events, in which
case it does not complete occur when an object arrives in a
state.

Analysis and Design of IS 14


• Entry and Exit Actions
 Entry and Exit actions specified in the state. It
must be true for every entry / exit occurrence. If
not, then you must use actions on the individual
transition arcs
• Entry Action executed on entry into state with
the notation: Entry / action
• Exit Action executed on exit from state with
the notation: Exit / action

Analysis and Design of IS 15


• Example - Entry / Exit Action (Check Book
Status)
 Illustrates a state machine diagram derived from a
Class - "BookCopy":

Analysis and Design of IS 16


Substates

• A simple state is one which has no


substructure.
• A state which has substates (nested states)
is called a composite state.
• Substates may be nested to any level. A
nested state machine may have at most one
initial state and one final state.
• Substates are used to simplify complex flat
state machines by showing that some states
are only possible within a particular context
(the enclosing state).

Analysis and Design of IS 17


• Substate Example - Heater

Analysis and Design of IS 18


History States

• Unless otherwise specified, when a transition enters a


composite state, the action of the nested state machine
starts over again at the initial state (unless the transition
targets a substate directly).
• History states allow the state machine to re-enter the last
substate that was active prior to leaving the composite
state.
• Example:

Analysis and Design of IS 19


Concurrent State

• As mentioned above, states in state machine diagrams can be nested.


Related states can be grouped together into a single composite state.
Nesting states inside others is necessary when an activity involves
concurrent sub-activities.
• The following state machine diagram models an auction with two
concurrent substates: processing the bid and authorizing the payment
limit.
• Example - Auction Process

Analysis and Design of IS 20


Activity Diagram

• Describe dynamic aspects of the system.


• Describe how activities are coordinated to provide a
service which can be at different levels of abstraction.
• It is also suitable for modeling how a collection of use
cases coordinate to represent business workflows
 Identify candidate use cases, through the examination of
business workflows
 Identify pre- and post-conditions (the context) for use cases
 Model workflows between/within use cases
 Model complex workflows in operations on objects
 Model in detail complex activities in a high level activity
Diagram

Analysis and Design of IS 21


• A basic activity
diagram - flowchart
like

Analysis and Design of IS 22


Activity Diagram Notation Summary

Notation Description Notation


Activity Is used to represent a set of
actions

Action A task to be performed

Control Flow Shows the sequence of


execution

Object Flow Show the flow of an object from


one activity (or action) to another
activity (or action).

Analysis and Design of IS 23


Notation Description Notation
Initial Node Portrays the beginning of a set of
actions or activities

Activity Final Stop all control flows and object


Node flows in an activity (or action)

Object Node Represent an object that is


connected to a set of Object
Flows
Decision Represent a test condition to
Node ensure that the control flow or
object flow only goes down one
path

Merge Node Bring back together different


decision paths that were created
usingofaIS
Analysis and Design decision-node. 24
Notation Description Notation
Fork Node Split behavior into a set of
parallel or concurrent flows of
activities (or actions)

Join Node Bring back together a set of


parallel or concurrent flows of
activities (or actions).

Swimlane A way to group activities


and Partition performed by the same actor on
an activity diagram or to group
activities in a single thread

Analysis and Design of IS 25


• The activity diagram example below
describes the workflow for a word process
to create a document through the
following steps:
 Open the word processing package.
 Create a file.
 Save the file under a unique name within its
directory.
 Type the document.
 If graphics are necessary, open the graphics
package, create the graphics, and paste the
graphics into the document.
 If a spreadsheet is necessary, open the
spreadsheet package, create the
spreadsheet, and paste the spreadsheet into
the document.
 Save the file.
 Print a hard copy of the document.
 Exit the word processing package.
Analysis and Design of IS 26
• Activity Diagram Example - Process Order

Analysis and Design of IS 27


• Activity Diagram Example - Student
Enrollment

Analysis and Design of IS 28


Activity Diagram - Swinlane

• A swimlane is a way to group activities


performed by the same actor on an activity
diagram or activity diagram or to group activities
in a single thread.
• An example of a swinlane activity diagram for
modeling Staff Expenses Submission:

Analysis and Design of IS 29


• Swinlane and Non-Swinlane Activity
Diagram

Analysis and Design of IS 30


Analysis and Design of IS 31

You might also like