State Transition Diagram with example in software engineering

What is the State transition Diagram?

When we write our program in Object-oriented programming, then we need to take classes and objects. Objects change their states during different functions/actions performed on objects.

In a state transition diagram, the states appear as rounded rectangles with the state names inside.

Symbols used in State Transition Diagram 

state transition diagram symbols
Figure: state transition diagram symbols

Terminologies of State Transition Diagram

State
In the state transition diagram, An object always remains in some state. Further, the state of the object may change after an event occur.

Event

Any activity that may trigger a state transition or can change the state.

Guard

In the state transition diagram, a guard is a boolean expression. Suppose if the guard is true, then it enables an event to trigger a transition.

Transition

The change of state within an object is represented with a transition. It is possible that an object changes its state when the transition occurs.

Action

One or more actions are taken by an object when the object changes a state.

Examples of State Transition Diagram

Case Study:

You need to develop a web-based application in such a way that users can search other users, and after getting search complete, the user can send the friend request to other users. If the request is accepted, then both users are added to the friend list of each other. If one user does not accept the friend request. The second user can send another friend request. The user can also block each other.

Solution:

  1. First of all, identify the object that you will create during the development of classes in oop
  2. Identify the actions or events
  3. Identify the possible states for an object
  4. Draw the diagram.

Object: friends 

Events or actions: Search to add a friend, add a friend, accept a friend, reject a friend, again add, block user and close.

States: Start, the friend added, friend rejected, user blocked and end.

state transition diagram in UML
Figure: state transition diagram

Example: Draw the state transition diagram of the OS process

draw the state transition diagram of the os process

List of UML tools for drawing the diagrams

Here, we are showing you a list of UML tools for drawing the diagrams.

ToolPublicly release (first time)Open source/ Not open sourceWhat Programming language they used?
Borland TogetherNot an open source
CacooOctober 2010Not an open sourceHTML5

CaseComplete

2004Not an open sourceC#
ConceptDraw PRO1993Not an open source
Edraw Max2004Not an open sourceC++
Gliffy2006-08-01Not an open sourceHTML5 and JavaScript
JDeveloperNot an open sourceJava
Lucidchart2008-12Not an open sourceHTML5,  JavaScript
Eclipse  2007Open SourceJava
Dia2004?Open SourceC
Magicraw1998Not an open sourceJava
Microsoft isio1992Not an open source
PlantUML1999-04-30Open SourceJava
Microsoft Visual Studio1997-02Not an open sourceC++, C#
Modelio2009Open SourceJava
MyEclipse2003Not an open sourceJava
NetBeans1996Open SourceJava
Open ModelSphere2002-02Open SourceJava
Papyrus2013-06-27Open SourceJava
PragmaDev Studio2002Not an open sourcePython, C, C++
Prosa UML Modeller1996Not an open sourceC/C++
NClass2006-10-15Open SourceC#
PowerDesigner1989Not an open source
Rational Rhapsody1996Not an open sourceC, C++, C#, Java, Ada
Rational Rose XDENot an open source
Rational Software ArchitectEarly 1990sNot an open sourceJava/C++
Rational System ArchitectNot an open source
Reactive Blocks2011-11-13Not an open sourceJava
UModel2005-05Not an open sourceJava, C#, Visual Basic
Rational Software Modeler2004-10-13Not an open source
PlantUML1999-04-30Open SourceJava
PlantUML1999-04-30Open SourceJava
Software Ideas Modeler2009-08-06Not an open sourceC#
StarUML2005-11-01Not an open sourceDelphi
Umbrello UML Modeller2006-09-09Open SourceC++, KDE
UML Designer2012Open SourceJava, Sirius
UMLet2005-11-05Open SourceJava
Umple2008Open SourceUmple, Java, PHP, Javascript
Visual Paradigm for UML2002-06-20Not an open sourceC++, Java
yEdNot an open sourceJava

Advantages of State Transition Diagram

  1. A state transition diagram is used to represent a finite state machine.
  2. A state transition diagram is a demonstration of how our objects and functions behave within the system.

When I can Use State Transition Diagram?

  1. When the system has some dependencies on the events or on the values in the past.
  2. State Transition diagram can be used when a software tester is testing the system for a finite set of input values.
  3. When the software tester focus is to understand the behavior of the object.
  4. When the software tester focus is to test the sequence of events that may occur in the system under test.

Frequently Asked Questions (FAQ)

In a state transition diagram, the circle at the right with a hollow border is the initial state.

True/False

Answer: False

In a state transition diagram, the circle to the left is the final state.

True/False

Answer: False

Topic Covered

State Transition Diagram with example in software engineering.

Subscribe for Friendship

Latest posts by Prof. Fazal Rehman Shamil (see all)

Buy advertisement space on T4Tutorials

For more details email [email protected]