RAGHU ENGINEERING COLLEGE
(Autonomous)
UNIFIED MODELLING LANGUAGE
UNIT-4
By
Mr. V.TATA RAO
Assistant Professor,
Dept of CSE
CONTENTS:
Advanced Behavioral Modeling
Events and signals
State machines
Processes and Threads
Time and space
State chart diagrams.
References:
https://www.geeksforgeeks.org/unified-modeling-language-uml-introduction/.
https://www.tutorialspoint.com/uml/uml_modeling_types.htm
Events and signals
“Things that happen” are called events. And each one represents the
specification of a significant occurrence that has a location in time and
space
Event may include 4 types
1.signals 2.Calls 3.Passing of time 4.Change in state.
Events may be synchronous or asynchronous, so modeling events is
wrapped up in the modeling of processes and threads.
Events may be external or internal.
An event is the specification of a significant occurrence that has a location
in time and space.
A signal, passing of time and change in state are asynchronous events. Calls
are generally synchronous events, representing invocation of an operation.
UML allows us to represent events graphically as shown below. Signals
may be represented as stereotyped classes and other events are represented
as messages associated with transitions which cause an object to move from
one state to another.
Asynchronous events are events that can happen at arbitrary
times eg:- signal, the passing of time, and a change of state.
Synchronous events, represents the invocation of an operation
eg:- Calls
External events are those that pass between the system and its
actors. Internal events are those that pass among the objects
that live inside the system.
A signal is an event that represents the specification of an
asynchronous stimulus communicated between instances.
TYPES OF EVENTS
SIGNALS EVENT
CALLS EVENT
TIME AND CHANGE EVENT
SENDING AND RECEIVING EVENT
Signal Event:
A signal event represents a named object that is dispatched
(thrown) asynchronously by one object and then received (caught)
by another. Exceptions are an example of internal signal
A signal event is an asynchronous event
Signal events may have instances, generalization relationships,
attributes and operations. Attributes of a signal serve as its
parameters
A signal event may be sent as the action of a state transition in a
state machine or the sending of a message in an interaction
Signals are modeled as stereotyped classes and the relationship
between an operation and the events by using a dependency
relationship, stereotyped as send.
Call Event
A call event represents the dispatch of an operation
A call event is a synchronous event
Figure shows Call Events.
Time and change events
A time event represents the passage of time.
In UML, we model the time event using the “after”
keyword followed by an expression that evaluates a period
of time.
A change event represents an event that represents a
change in state or the satisfaction of some condition.
In UML, change event is modeled using the keyword
“when” followed by some Boolean expression.
Sending and Receiving Events:
Any instance of a class can receive a call event or signal. If this is a
synchronous call event, the sender is in locked state with receiver. If
this is a signal, then the sender is free to carry its operations without
any concern on the receiver.
In UML, call events are modeled as operations on the class of an
object and signals that an object can receive are stored in an extra
component in the class as shown below:
Common Modeling Techniques
1.Modeling a family of signals:
2.Modeling Exceptions:
1.Modeling a family of signals:
1. Consider all the signals to which a set of objects can respond.
2. Arrange these signals in a hierarchy using generalization-
specialization relationship.
3. Look out for polymorphism in the state machine of the active
objects. When polymorphism is found, adjust the hierarchy by
introducing intermediate abstract signals.
Common Modeling Techniques
Modeling a family of signals:
Common Modeling Techniques
2.Modeling Exceptions:
1. For each class and interface and for each operation of such elements,
consider the exceptional conditions that might arise.
2. Arrange these exceptions in a hierarchy.
3. For each operation, specify the exceptions that it may rise.
Common Modeling Techniques
State machine
• A state machine is a behavior that specifies the sequences of states
an object goes through during its lifetime in response to events.
• Graphically, a state is rendered as a rectangle with rounded
corners. A transition is rendered as a solid directed line.
• state machine are used to specif the behavior of objects that must
respond to asynchronous stimulus or whose current behavior
depends on their past.
• state machines are used to model the behavior of entire systems,
especially reactive systems, which must respond to signals from
actors outside the system.
State machine
STATES
• A state is a condition or situation during the life of an object during which
it satisfies some condition, performs some activity, or waits for some
event.
• An object remains in a state for a finite amount of time. For example, a
Heater in a home might be in any of four states: Idle, Activating, Active,
and ShuttingDown.
• a state name must be unique within its enclosing state
• A state has five parts:
1. Name,
2. Entry/exit actions,
3. Internal transitions – Transitions that are handled without causing a
change in state,
4. Substates – nested structure of a state, involving disjoint (sequentially
active) or concurrent (concurrently active) substates,
5. Deferred events – A list of events that are not handled in that state but,
rather, are postponed and queued for handling by the object in another
Example
Initial and Final States:
There are two special states that may be defined for an object’s state
machine.
First, the initial state, which indicates the default starting place of
control for the state machine or sub state.
Initial state is represented as a filled black circle. Second, the final
state, which indicates that the execution of the state machine or the
enclosing state has been completed.
Final state is represented as filled black circle enclosed in a hollow
circle.
Transitions:
A transition is a relationship between two states indicating that an
object in one state will perform certain actions and enter another
state when a specified event occurs and specified conditions are
satisfied.
A Transition has Five parts:
1. Source state
2. Event trigger
3. Guard condition
4. Action
5. Target state
Source state
The state affected by the transaction is in the source state, an
outgoing transaction may fire when the object receives the trigger event
of the transaction and if the guard condition is satisfied.
Event Trigger:
An event is a specification of a significant occurrence that has location
in time and space. In state machines, an event is an occurrence of
stimulus that can trigger a state transition. For example, the “play
button” makes the music player to change from “idle” state to
“playing”.
There can be triggerless transitions which are represented by a
transition with no event trigger. A triggerless transition also called a
completion transition is triggered implicitly when its source state has
completed its activity.
Guard Condition:
A guard condition is rendered as a Boolean expression enclosed in
square brackets and placed after the trigger event. A guard condition is
evaluated only after the trigger event for its transition occurs.
Therefore, it’s possible to have multiple transitions from the same
source state and with the same event trigger, as long as those conditions
don’t overlap.
Action:
An action is an executable atomic computation. Actions may be method
calls, signals or creation of objects or destruction of objects.
PROCESS AND THREADS
A process is a heavyweight flow that can execute concurrently
with other processes.
A thread is a lightweight flow that can execute concurrently with
other threads within the same process.
An active object is an object that owns a process or thread and
can initiate control activity.
An active class is a class whose instances are active objects.
Graphically, an active class is rendered as a rectangle with thick
lines. Processes and threads are rendered as stereotyped active
classes. Figure 1:Active class
CLASSES AND EVENTS
Active classes are just classes which represents an independent
flow of control
Active classes share the same properties as all other classes.
When an active object is created, the associated flow of control
is started; when the active object is destroyed, the associated
flow of control is terminated
two standard stereotypes that apply to active classes
are, <<process>> – Specifies a heavyweight flow that can
execute concurrently with other processes. (heavyweight means,
a thing known to the OS itself and runs in an independent
address space) <<thread>> – Specifies a lightweight flow that
can execute concurrently with other threads within the same
process (lightweight means, known to the OS itself.)
All the threads that live in the context of a process are peers of
one another.
Figure shows part of the process view of a trading system.
SYNCHRONIZATION
Synchronization on means arranging the flow of controls of objects so
much mutual exclusion will be guaranteed.
In object oriented systems these objects are treated as a criteria region
Three approaches are there to handle synchronization
1.sequential:-Callers must coordinate outside the object so that only one
flow is in the object at a time.
2.Guarded:Multiple flow of control is sequentialized with the help of
object’s guarded operations.in effect it becomes sequential.
3.Concurrent:-multiple flow of control is guaranteed by treating each
operation as atomic.
Synchronization are rendered in the operations of active classes with the
help of constraints.
TIME AND SPACE
Real time and distributed systems require the ability to model time and
space. The UML provides the ability to visualize, specify, construct,
and document these types of systems using timing marks, time
expressions, constraints, and tagged values.
A real time system is one that requires a certain behavior to be carried
out at a precise time, and for a specific duration.
A distributed system is one that requires the ability to physically
distribute components across nodes. A node may mean different
processors physically located on the same box or in different locations.
The UML elements used to meet the modeling requirements of real
time and distributed systems include:
• Timing marks
• Time expressions
• Timing constraints
• Location
TIME
Real time systems are by definition, time-critical systems.
This means that events, and responses to events occur at
regular or irregular times that are predictable. To represent
time, each message that is used in an interaction can be
identified by name, to be used as a timing mark. This is what
we mean when we say a timing mark is nothing more than an
expression formed from the name of message in an
interaction. Given the message name then, you can refer to
three functions of the message:
StartTime
StopTime
ExecutionTime
LOCATION
Distributed systems, encompass components that are physically
scattered among the nodes of a system.
For many ststems, components are fixed in place at the time they are
loaded on the system; in other systems, components may migrate
form node to node.
STATE CHART DIAGRAM
State chart diagram is simply a presentation of a state machine which
shows the flow of control from state to state.
State chart diagrams are important for constructing executable
systems through forward and reverse engineering.
state chart diagrams are useful in modeling the lifetime of an object
State chart diagrams commonly contain – Simple states and
composite states, Transitions- including events and actions It is one
of the five diagrams in UML for modeling the dynamic aspects of
systems.
Graphically, a state chart diagram is a collection of vertices and arcs.
STATE CHART DIAGRAM
A state is a condition or situation in the life of an object during
which it satisfies some condition, performs some activity, or waits
for some event.
An event in the context of state machines is an occurrence of a
stimulus that can trigger a state transition.
A transition is a relationship between two states indicating that an
object in the first state will perform certain actions and enter the
second state when a specified event occurs and specified
conditions are satisfied.
An activity is ongoing non atomic execution within a state
machine. An action is an executable atomic computation that
results in a change in state of the model or the return of a value.
A reactive or event-driven object is one whose behavior is best
characterized by its response to events dispatched from outside its
PURPOSE OF STATECHART DIAGRAMS
• State chart diagram is one of the five UML diagrams used to model
the dynamic nature of a system.(use case, sequence, collaboration,
activity, state chart diagram)
• They define different states of an object during its lifetime and these
states are changed by events.
• State chart diagrams are useful to model the reactive systems.
• Reactive systems can be defined as a system that responds to external
or internal events.
• State chart diagram describes the flow of control from one state to
another state.
• States are defined as a condition in which an object exists and it
changes when some event is triggered.
• The most important purpose of Statechart diagram is to model
lifetime of an object from creation to termination.
PURPOSE OF STATECHART DIAGRAMS
• State chart diagrams are also used for forward and reverse engineering
of a system. However, the main purpose is to model the reactive
system.
• Following are the main purposes of using State chart diagrams −
To model the dynamic aspect of a system.
To model the life time of a reactive system.
To describe different states of an object during its life time.
Define a state machine to model the states of an object.
HOW TO DRAW A STATECHART DIAGRAM?
Statechart diagram is used to describe the states of different objects in its
life cycle. Emphasis is placed on the state changes upon some internal or
external events. These states of objects are important to analyze and
implement them accurately.
Statechart diagrams are very important for describing the states. States
can be identified as the condition of objects when a particular event
occurs.
Before drawing a Statechart diagram we should clarify the following
points −
•Identify the important objects to be analyzed.
•Identify the states.
•Identify the events.
HOW TO DRAW A STATECHART DIAGRAM?
Following is an example of a Statechart diagram where the state of Order
object is analyzed
The first state is an idle state from where the process starts. The next
states are arrived for events like send request, confirm request, and
dispatch order. These events are responsible for the state changes of
order object.
During the life cycle of an object (here order object) it goes through the
following states and there may be some abnormal exits. This abnormal
exit may occur due to some problem in the system. When the entire life
cycle is complete, it is considered as a complete transaction as shown in
the following figure. The initial and final state of an object is also shown
in the following figure.
HOW TO DRAW A STATECHART DIAGRAM?
WHERE TO USE STATECHART DIAGRAMS?
From the above discussion, we can define the practical applications of
a Statechart diagram.
Statechart diagrams are used to model the dynamic aspect of a system
like other four diagrams discussed.
However, it has some distinguishing characteristics for modeling the
dynamic nature.
Statechart diagram defines the states of a component and these state
changes are dynamic in nature.
Its specific purpose is to define the state changes triggered by events.
Events are internal or external factors influencing the system.
Statechart diagrams are used to model the states and also the events
operating on the system.
When implementing a system, it is very important to clarify different
states of an object during its life time and Statechart diagrams are
used for this purpose.
WHERE TO USE STATECHART DIAGRAMS?
When these states and events are identified, they are used to model it
and these models are used during the implementation of the system.
If we look into the practical implementation of Statechart diagram,
then it is mainly used to analyze the object states influenced by
events.
This analysis is helpful to understand the system behavior during its
execution.
The main usage can be described as −
•To model the object states of a system.
•To model the reactive system. Reactive system consists of reactive
objects.
•To identify the events responsible for state changes.
•Forward and reverse engineering.
ATM
Library Management System
THANK YOU
ANY
QUERIES