Professional Documents
Culture Documents
An activity diagram visually presents a series of actions or flow of control in a system similar
to a flowchart or a data flow diagram. Activity diagrams are often used in business process
modeling. They can also describe the steps in a use case diagram. Activities modeled can be
sequential and concurrent.
Activity Diagrams describe how activities are coordinated to provide a service which can
be at different levels of abstraction. Typically, an event needs to be achieved by some
operations, particularly where the operation is intended to achieve a number of different
things that require coordination, or how the events in a single use case relate to one another,
in particular, use cases where activities may overlap and require coordination. It is also
suitable for modeling how a collection of use cases coordinate to represent business
workflows
1. Identify candidate use cases, through the examination of business workflows
2. Identify pre- and post-conditions (the context) for use cases
3. Model workflows between/within use cases
4. Model complex workflows in operations on objects
5. Model in detail complex activities in a high level activity Diagram
The purpose of an activity diagram can be described as −
Draw the activity flow of a system.
Describe the sequence from one activity to another.
Describe the parallel, branched and concurrent flow of the system.
captures the dynamic behavior of the system.
Other four diagrams are used to show the message flow from one object to another
but activity diagram is used to show message flow from one activity to another.
Activity is a particular operation of the system. Activity diagrams are not only used
for visualizing the dynamic nature of a system, but they are also used to construct the
executable system by using forward and reverse engineering techniques. The only
missing thing in the activity diagram is the message part.
It does not show any message flow from one activity to another. Activity diagram is
sometimes considered as the flowchart.
Student enrolment number.
Synchronization
A fork node is used to split a single incoming flow into multiple concurrent flows. It is
represented as a straight, slightly thicker line in an activity diagram.
A join node joins multiple concurrent flows back into a single outgoing flow.
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.
Interrupting Edge
An event, such as a cancellation, that interrupts the flow denoted with a lightning bolt.
Swimlanes
Swimlanes group related activities into one column.
Activity Diagram - Swimlane
A swim lane diagram, also called a cross functional flow chart, or swim lane process map, is
an element used in mapping process workflows. It groups components into a distinct
sequence, or lane, in the visual presentation of workflow and process charts. Swimlane
diagrams distinguish capabilities, roles, and responsibilities for each sub-process in business
process workflows.
In swim lane maps, parallel lines divide the chart into lanes, hence the name, with one lane
for each person, group or sub process.
For example, a vertical lane may represent a sequence of events, while the horizontal lanes
depict what department, person, or material is involved, with arrows and other standard
symbols to show how the actual process workflow takes place.
BENEFIT
– At high level, Use cases describes how a system interacts with outside actors
– Sequence diagrams provide more detail and show the messages exchanged
among a set of objects over time
Activity diagrams provide details and show the flow of control among the steps of a
computation
The purpose of interaction diagrams is to visualize the interactive behavior of the system.
Visualizing the interaction is a difficult task. Hence, the solution is to use different types of
models to capture the different aspects of the interaction.
Sequence and collaboration diagrams are used to capture the dynamic nature but from a
different angle.
The purpose of interaction diagram is −
To capture the dynamic behaviour of a system.
To describe the message flow in the system.
To describe the structural organization of the objects.
To describe the interaction among objects.
WHERE TO USE THEM –
equence diagrams are used to capture the order of messages flowing from one object to
another. Collaboration diagrams are used to describe the structural organization of the
objects taking part in the interaction. A single diagram is not sufficient to describe the
dynamic aspect of an entire system, so a set of diagrams are used to capture it as a whole.
Interaction diagrams are used when we want to understand the message flow and the
structural organization. Message flow means the sequence of control flow from one object to
another. Structural organization means the visual organization of the elements in a system.
Interaction diagrams can be used −
To model the flow of control by time sequence.
To model the flow of control by structural organizations.
For forward engineering.
For reverse engineering.
SEQUENCE DIAGRAM-
ADVANTAGE-
Used to model and visualise the logic behind a sophisticated function, operation or
procedure.
They are also used to show details of UML use case diagrams.
Used to understand the detailed functionality of current or future systems.
Visualise how messages and tasks move between objects or components in a system.
COLLABORATION OR COMMUNICATION DIAGRAM –
Collaboration diagrams (known as Communication Diagram in UML 2.x) are used to show how
objects interact to perform the behavior of a particular use case, or a part of a use case. Along with
sequence diagrams, collaboration are used by designers to define and clarify the roles of the objects
that perform a particular flow of events of a use case. They are the primary source of information
used to determining class responsibilities and interfaces.
In UML, each thing that happens is modeled as an event. 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.
Types of Events
Events may be external or internal. Events passed between the system and its actors are
external events. For example, in an ATM system, pushing a button or inserting a card are
external events. Internal events are those that are passed among objects living inside the
system. For example, a overflow exception generated by an object is an internal event.
In UML, we can model four kinds of events namely: signals, calls, passing of time and
change in state.
Signals
A signal is a named object that is sent asynchronously by one object and then received by
another. Exceptions are the famous examples for signals. A signal may be sent as the action
of a state in a state machine or as a message in an interaction. The execution of an operation
can also send signals.
In UML, we model the relationship between an operation and the events using a dependency
stereotyped with “send”, which indicates that an operation sends a particular signal.
Call Events
A call event represents the dispatch of an operation from one object to another. A call event
may trigger a state change in a state machine. A call event, in general, is synchronous.
This means that the sender object must wait until it gets an acknowledgment from the
receiver object which receives the call event. For example, consider the states of a customer
in an ATM application:
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.
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:
Statechart diagram -
A Statechart diagram describes a state machine. State machine can be defined as a machine
which defines different states of an object and these states are controlled by external or
internal events.
Activity diagram explained in the next chapter, is a special kind of a Statechart diagram. As
Statechart diagram defines the states, it is used to model the lifetime of an object.
Statechart diagram is one of the five UML diagrams used to model the dynamic nature of a
system. They define different states of an object during its lifetime and these states are
changed by events. Statechart diagrams are useful to model the reactive systems. Reactive
systems can be defined as a system that responds to external or internal events.
Statechart 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.
Statechart 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 Statechart 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.
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. 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.
Types of State
Unified Modeling Language defines three types of states:
Simple state
o They do not have any substrate.
Composite state
o These types of states can have one or more than one
substrate.
o A composite state with two or more substates is called
an orthogonal state.
Submachine state
o These states are semantically equal to the composite
states.
o Unlike the composite state, we can reuse the
submachine states.
Statemachine FlowChart
The state machine has a WAIT The Flowchart does not deal with
concept, i.e., wait for an action or waiting
an event.
for a concept.
of a system.
The state machine can explore Flowchart deal with paths and contr
various states of a system. flow.
Kinds of Events
• Change event
– Event caused by satisfaction of a Boolean expression
– Intent: Expression continually tested; when changes from
false to true, the event happens
– UML Notation: keyword when followed by
parenthesized boolean expression
• when(room temperature < heating set point)
• when(room temperature > cooling set point)
• when(battery power < lower limit)
• when(tire pressure < minimum pressure
• Time event
– Event caused by the occurrence of an absolute time or the
elapse of a time interval
– for absolute time the UML Notation: keyword when
followed by parenthesized expression involving time
• when (date = Jan 1, 2013)
– for time interval the UML Notation: keyword after
followed by parenthesized expression that evaluate to a
time duration
• after (n timeUnits)
after(10 seconds)
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.
Figure 1 shows State Machines
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.
Flow of Control
In a sequential system, there is a single flow of control. i.e, one thing, and one thing only,
can take place at a time.
In a concurrent system, there is multiple simultaneous flow of control i.e, more than one
thing can take place at a time.
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
Communication
In a system with both active and passive objects, there are four possible
combinations of interaction
First, a message may be passed from one passive object to another
Second, a message may be passed from one active object to another
In inter-process communication there are two possible styles of
communication. First, one active object might synchronously call an operation of
another. Second, one active object might asynchronously send a signal or call an
operation of another object
a synchronous message is rendered as a full arrow and an asynchronous message
is rendered as a half arrow
Figure 2: shows Communication
Third, a message may be passed from an active object to a passive object
Fourth, a message may be passed from a passive object to an active one
Figure 2: Communication
Synchronization
synchronization means arranging the flow of controls of objects so that mutual
exclusion will be guaranteed.
in object-oriented systems these objects are treated as a critical region
Figure 3 Synchronization
three approaches are there to handle synchronization:
Sequential – Callers must coordinate outside the object so that only one flow is in
the object at a time
Guarded – multiple flow of control is sequentialized with the help of object’s
guarded operations. in effect it becomes sequential.
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
Figure 3: Synchronization
Process Views
The process view of a system encompasses the threads and processes that form
the system’s concurrency and synchronization mechanisms.
This view primarily addresses the performance, scalability, and throughput of the
system.
Modeling Multiple Flows of Control
To model multiple flows of control,
· Identify the opportunities for concurrent action and reify each flow as an active
class. Generalize common sets of active objects into an active class. Be careful not to
overengineer the process view of your system by introducing too much concurrency.
· Consider a balanced distribution of responsibilities among these active classes,
then examine the other active and passive classes with which each collaborates statically.
Ensure that each active class is both tightly cohesive and loosely coupled relative to these
neighboring classes and that each has the right set of attributes, operations, and signals.
· Capture these static decisions in class diagrams, explicitly highlighting each
active class.
· Consider how each group of classes collaborates with one another dynamically.
Capture those decisions in interaction diagrams. Explicitly show active objects as the root
of such flows. Identify each related sequence by identifying it with the name of the active
object.
· Pay close attention to communication among active objects. Apply synchronous
and asynchronous messaging, as appropriate.
· Pay close attention to synchronization among these active objects and the
passive objects with which they collaborate. Apply sequential, guarded, or concurrent
operation semantics, as appropriate.
Figure 4 shows part of the process view of a trading system.
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
Example:
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
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:
1. An element is in a source state
2. An event occurs
3. An action is performed
4. 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
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
DO ACTIVITIES-
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
Example - Entry / Exit Action (Check Book Status)
This example illustrates a state machine diagram derived from a Class - "BookCopy":
Note:
1. This state machine diagram shows the state of an object myBkCopy from a
BookCopy class
2. Entry action : any action that is marked as linked to the entry action is executed
whenever the given state is entered via a transition
3. Exit action : any action that is marked as linked to the exit action is executed
whenever the state is left via a transition
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).
Substate Example - Heater
State Machine Diagrams are often used for deriving testing cases, here is a list of possible test
ideas:
Idle state receives Too Hot event
Idle state receives Too Cool event
Cooling/Startup state receives Compressor Running event
Cooling/Ready state receives Fan Running event
Cooling/Running state receives OK event
Cooling/Running state receives Failure event
Failure state receives Failure Cleared event
Heating state receives OK event
Heating state receives Failure event
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. An example of history state usage is
presented in the figure below.
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.
Concurrent State Machine Diagram Example - Auction Process
In this example, the state machine first entering the Auction requires a fork at the start into
two separate start threads. Each substate has an exit state to mark the end of the thread.
Unless there is an abnormal exit (Canceled or Rejected), the exit from the composite state
occurs when both substates have exited.
ADVANCE STATE DIAGRAM-
• Expanding state
– UML Notation for submachine: list a local name followed by a colon and
the submachine name.
NESTED STATE-
– triggered by an event
– Transition is said to fire upon the change from source to target state
– Origin and target state of a transition are different states but may be the
same
– e.g., when a phone line is answered, the phone line transitions from the
Ringing state to the Connected state.
• Guard Condition:
– checked only once, at the time event occurs; transition fires if true
– E.g., when you go out in the morning (event), if the temperature is below
freezing (condition), then put on your gloves (next state).
SIGNAL GENREALISATION-
• Organize signals into generalization hierarchy with inheritance of signal
attributes
• Received signal triggers transitions that are defined for any ancestor signal type.
– E.g., some state might handle all i/p characters the same; other states
might treat control characters differently from printing characters .
AGGREGATION CURRENCY-
• State Aggregation means collection of state diagrams , one for each part
• “and” relationship
• Aggregate state is one state from first diagram & a state from second diagram &
state from each other diagram.
• Transition for one object depend on another object, allows interaction between
the state diagram.
• The state of the object comprises one state from each subdiagram.
• The sub diagrams need not be independent; the same event can cause transitions
in more than one subdiagram
• UML Notation- partition the composite state into regions with dotted lines.
• A state diagram describes all or part of the behavior of the objects of a given
class.
• State model of a class is inherited by its subclasses. Subclass inherits both the
state & Transitions.
COMPONENT DIAGRAM _
Component diagrams are used to model the physical aspects of a system. Now the
question is, what are these physical aspects? Physical aspects are the elements
such as executables, libraries, files, documents, etc. which reside in a node.
Component diagrams are used to visualize the organization and relationships
among components in a system. These diagrams are also used to make executable
systems.