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

Lecture 09

State chart diagram

Uploaded by

clmc0811
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)
27 views

Lecture 09

State chart diagram

Uploaded by

clmc0811
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
You are on page 1/ 20

Lecture 09: State Chart Diagrams

CSC212A Software Development Fundamentals

Course Leader(s):
Ms.Sahana.P.Shankar
[email protected]
Ms. Supriya, M. S.
[email protected]

1
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Lecture Objectives

• At the end of this lecture, student will be able to


– Identify the basic building blocks of UML State diagrams
– Explain the concepts of object oriented design
– Model the behavior of objects in a software system with State diagrams
– Design the behavior of objects in a given software system with object
oriented approach

2 2
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
Lecture Topics

• State diagrams
• State chart diagram
• State machine and transitions
• Activity diagram
• Interaction overview diagrams
• Elements in State diagram
• Relationships in State diagram

3 3
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
State-chart Diagram

• State-chart diagrams address the dynamic view of a system


• A state-chart diagram shows a state machine, consisting of
– States
– Transitions
– Events
– Activities

• They used to model the behavior of an interface, class or


collaboration
• In object-oriented approaches, you draw a state machine
diagram for a single class to show the lifetime behavior of a
single object
4 4
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
State-chart Diagram

• State diagrams are good at


– Describing the behavior of an object across several use
cases
• State diagrams are not very good at
– Describing behavior that involves a number of objects
collaborating

• A State machine
– A behavior that specifies the sequences of states an object
goes through during its lifetime in response to events,
together with its responses to those events

5 5
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
State Machine

• A state
– Condition or situation during the life of an object during
which it satisfies some condition, performs some activity,
or waits for some event
• An event
– The specification of a significant occurrence that has a
location in time and space
• An action
– Executable atomic computation that results in a change in
state of the model or the return of a value
• Transition
– Indicates a movement from one state to another
6 6
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
Transition

Each transition has a label that comes in three parts


trigger-signature [guard]/activity
• The trigger-signature
– A single event that triggers a potential change of state
• The guard
– If present, is a Boolean condition that must be true for
the transition to be taken
• The activity
– Some behavior that's executed during the transition
– It may be any behavioral expression

7 7
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
Transition

All three parts to a transition are optional


– A missing activity indicates that you don't do anything
during the transition
– A missing guard indicates that you always take the
transition if the event occurs
– A missing trigger-signature is rare but does occur. It
indicates that you take the transition immediately, which
you see mostly with activity states

8 8
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
State Machine
Graphically
– A state is rendered as a rectangle with rounded corners
– A transition is rendered as a solid directed line

9 9
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
State Machine Diagrams

• The final state indicates that the state machine is completed,


implying the deletion of the controller object

• When an event occurs in a state,


– You can take only one transition out of it

• If you use multiple transitions with the same event


– The guards must be mutually exclusive

• If an event occurs and no transition is valid


– The event is ignored
10 10
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
Internal Activities

• Internal activities
– To react to events without transition in states
– Putting the event, guard, and activity inside the state box
itself
• An internal activity is similar to a self-transition: a transition
that loops back to the same state

11 11
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
Activity Diagram

• Address the dynamic view of a system


• An activity diagram is a special kind of a state-chart diagram
• It shows the flow from activity to activity within a system

• Activity diagrams
– Are used in modelling the function of a system
– Emphasize the flow of control among objects
– Collection of vertices and arcs
– A technique to describe procedural logic, business process,
and work flow
– They support parallel behavior (unlike flowcharts)

12 12
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
Activity Diagram

13 13
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
Activity Diagram

Activity diagrams commonly contain


– Action states
• Executable atomic computations
• They can not be further decomposed
• The nodes on an activity diagram
– Activity states
• Can be further decomposed
• Their activity can be represented by other activity
diagrams

14 14
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
Activity Diagram

– Transitions
• To specify the flow of control from one action/activity
state to the next action/activity state
• Represented as a simple directed line

– Objects
• Objects may be involved in the flow of control
associated with an activity diagram

15 15
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
Activity Diagrams

• Fork
– A fork has one incoming flow and several outgoing
concurrent flows

• Join
– With a join, the outgoing flow is taken only when all the
incoming flows reach the join

• Decision
– A decision, called branch 1, has a single incoming flow and
two guarded out-going flows
16 16
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
Activity Diagrams

• Guard
– Each outbound flow has a guard
– A Boolean condition placed inside square brackets
– Each time you reach a decision, you can take only one of
the outbound flows, so the guards should be mutually
exclusive

• Merge
– A merge has multiple input flows and a single output
– A merge marks the end of conditional behavior started by a
decision

17
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
A Simple Activity Diagram

18
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
Tokens

• The initial node creates a token, which then passes to the next
action, which executes and then passes the token to the next
• At a fork
– One token comes in, and the fork produces a token on each
of its outward flows
• On a join
– As each inbound token arrives, nothing happens until all
the tokens appear at the join; then a token is produced on
the outward flow

19
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences
Summary
• State diagrams are good at describing the behavior of an
object across several use cases
• State diagrams are not very good at describing behavior that
involves a number of objects collaborating

• A State machine specifies the sequences of states an object


goes through during its lifetime in response to events,
together with its responses to those events
• A state-chart diagram shows a state machine, consisting of
– States
– Transitions
– Events
– Activities
20
Faculty of Engineering & Technology ©Ramaiah University of Applied Sciences

You might also like