0% found this document useful (0 votes)
10 views40 pages

Unit 4

The document provides an overview of dynamic modeling in systems, focusing on UML diagrams such as sequence, collaboration, activity, and state diagrams to illustrate the dynamic aspects of a system. It explains the elements and creation processes for each diagram type, emphasizing how they represent interactions, activities, and state transitions over time. Additionally, it discusses the importance of modeling workflows and collaborations among classes to depict cooperative behaviors in a system.

Uploaded by

zegangaming123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views40 pages

Unit 4

The document provides an overview of dynamic modeling in systems, focusing on UML diagrams such as sequence, collaboration, activity, and state diagrams to illustrate the dynamic aspects of a system. It explains the elements and creation processes for each diagram type, emphasizing how they represent interactions, activities, and state transitions over time. Additionally, it discusses the importance of modeling workflows and collaborations among classes to depict cooperative behaviors in a system.

Uploaded by

zegangaming123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 40

Unit-4

Dynamic
Modeling
Introduction
 “Dynamic Model describes the control
aspects of the system that change over
time”
 UML’s four diagrams are used to visualize,
specify, construct, and document the
dynamic aspects of a system:
 Sequence diagram (Interaction
Diagram)
 Collaboration diagram

 Activity diagram

 State chart diagram


Sequence Diagram
 “ Sequence diagrams describe interactions
among classes in terms of an exchange of
messages over time”
 When an object passes a message to another
object, the receiving object might send
another message, this stream of messages
forms a sequence. The message are ordered
in sequence by time.
 Modeling the flow of control by time ordering
emphasizes the passing of messages as they
unfold over time, which is a useful way to
visualize dynamic behavior of the system
Elements of Sequence
diagram
 Class Roles:- they describe the way an
object will behave in context, but don’t list
object attributes
Object Name : Class Name

 Actor:- An external entity that interacts


with the system

 Lifelines:- Lifelines are vertical dashed lines


that indicate the object’s presence over
time. If the lifeline extends to the bottom of
the diagram, the object will continue to
exist during the entire session of interaction
(Lifelines)
 Messages:- Messages are arrows that
represent communication between
objects. Each message sent to a class
invokes a method on that class. When
an operation is completed, the object
returns the parameters to calling
object using return message.
 Synchronous (sender
sends the message to receiver and wait
for the procedure completion of receiver)
 Simple (One object
sends the message to the passive object)
 Asynchronous (The
sender sends the message and
immediately continues with the next step)
 Return ( return message
from called procedure of the receiver to
the sender)
 delayed message
 Activation:- Activation boxes represent the time
an object needs to complete a task. It
represents the time during which object is
active.

Activations->

 Creating/Deleting Objects:- Objects can be


created and deleted during the interaction. By
sending a message an object can dynamically
create or delete an object. After deleting an
object show ‘ X’ (a cross sign) on its
lifeline.
<<Create>> <<Delete>>
 Simple and Block Iteration:-
Sometimes a task is to be performed
repeatedly, then in sequence diagram task is
represented by a name preceded by an
asterisk “ * ”.
Sometimes the execution of a block of messages
may be repeated. A repetition or loop within a
sequence diagram is depicted as a rectangle.
Place the condition for exiting the loop in
square brackets [ ] .
 Branching:- It represent conditional or

concurrent action and it is represented by


multiple arrows leaving the same point of
objects lifeline. If the conditions of messages
are mutually exclusive, the branch is a
conditional otherwise it is concurrent.
 Scenarios and Event traces:-
A scenario is a sequence of events
that occur during one particular
execution of the system. It may
include all events in the system or
only those events that are generated
by certain objects in the system.
Creating Sequence Diagram
 For drawing the sequence diagram:-
 Identify the scenario
 Identify the actors
 Identify the sender and receiver objects
 Place objects along X-axis from left to
right
 Draw the lifelines of all the objects
 Identify the events in the scenario
 Show the messages from top to bottom
that are transferred among objects with
proper parameters
 Show the activation lines for all objects
 Show the repeatable task by name
followed by an asterisk “ * ”
L : Librarian B : Book MR: Member Record

1 : Check availability of book


2 : book available, rack no.

3 : validate member
T : Transaction
4 : check number of books issued
5 : book can be issued
6 : <<create>>

7 : Add member and book details

8 : Update book status

9 : update member record


Collaboration Diagram
 A Collaboration diagram is an
interaction diagram that emphasizes the
structural organization of the objects
that send and receive messages.
 Collaboration diagram express similar
information as in sequence diagram, but
in a different way.
 It describes a specific scenario.
Numbered arrows show the movement
of messages during the course of a
scenario.
 A collaboration diagram shows the
object and their association with other
objects in the system apart from how
they interact with each other. The
association between objects is not
represented in a sequence diagram.
 Collaboration diagrams provides a way
to model scenarios. Each object is
represented by an object icon, and
lines created to indicate common path.
Elements Of a Collaboration
diagram
 Object: The objects interacting with
each other in the system. It is
depicted by a rectangle with the
name of the object in it, preceded by
a colonObject
and underlined.
Name : Class Name

 Association: A link connecting the


associated objects
 Messages: An arrow pointing from the
commencing object to the destination
object shows the interaction between
the objects. The number represents the
order/sequence of this interaction.
Each message represented with a
sequence number that precedes it. The
sequential numbering of messages
allows us to easily trace the message in
a collaboration diagram
1 : Function( )
Creating Collaboration
diagram
 Following steps can be used to create
the diagram:
 Place the objects that participate in the
interaction as the vertices in a graph
 Add links that connect these objects as
the arcs of the graph
 Adorn these links with the messages that
objects sends and receive with sequence
numbers
 If needed, attach time constraints, pre
and post conditions to each message.
2 Dial tone begins
4 Dial tone ends
6.1 ringing tone : Caller
8.1 tone stops
9.1Phone connected
11.1Connection Broken

1 caller lifts receiver


6 male call route 3 dial digits (5)
op ringing at caller and callee 5 dial digits*
connect caller and callee 10 caller hangs up
11 end connection

6.2 phone rings


: Phone line 8.2 ringing stops
9.2 phone connected
11.2 connection broken

7 lift
12 callee
receiver
hangs up : Callee
Choosing between sequence and
collaboration
 Sequence diagram are better choice :-
 When we want the reader to be able to easily
see the order in which messages occur.
 When we want to build an interaction model
from a use case. Use cases already have a
sequence of steps. Sequence diagrams
expands on these to show which objects are
involved
 Collaboration diagram are better choice:-
 When we want to build an interaction model
from a class diagram since they effectively
show instances with communication links.
 They can also be used to help in validation of
class diagram
Activity Diagram
 “Activity diagram is a dynamic model
which shows the activity and the event
that causes the object to be in the
particular state”
 Activity diagrams do not give details
about how objects behave or how objects
collaborate. They shows the effect of
external events on internal processing.
 Activity diagrams are useful for
analyzing a use case by describing what
actions needs to take place and when
they should occur.
Elements of Activity
diagram
 Initial Activity:- It shows the starting
point or first activity of the flow and
denoted by a solid circle. There can
be only one initial state in a
diagram.

 Activity:- Represented by a rectangle


with rounded edges.
ACTIVITY
 Transition:- When an activity state is
completed, processing moves to
another activity state and are shown
by transitions.
event[ guard condition]/action

 Decisions:- A logic where decision is


to be made is depicted by a
diamond, with the options written on
either side of the arrows

[opt1] [opt2]
 Synchronization bar[ fork and join]:-
Activities can be done in parallel. To
split processing (“fork”), or to resume
processing when multiple activities
have been completed( “join”),
synchronization bars are used.

 Final Activity:- The end of the activity


diagram is shown by a bull’s eye
symbol. An activity diagram can have
zero or more activity final nodes.
Creating an Activity
diagram
 Diagrams are read from top to bottom and
have branches and forks to describe
conditions and parallel activities.
 A fork is used when multiple activities are
occurring at the same time.
 The branch describes what activities will
take place based on a set of conditions.
 All branches at some point are followed by
a merge to indicate the end of the
condition.
 After the merge, all of the parallel activities
must be combined by a join before
transitioning into the final activity state.
Activity diagram
for processing
an order Receive order

Fill Order Send Invoice

[Rush order] [Normal Order]


Receive Payment
Fast Delivery Regular Delivery

Close Order
Modeling Workflow
(Swim lanes)
 Workflows represent the flow of work and
objects through the business. We can use
activity diagrams to model a workflow.
 If we wish to distinguish in an activity
diagram, the activities carried out by
individual actors, then we draw swim lanes.
 Firstly the vertical columns are made,
separated by thick vertical black lines, and
name each of these columns with the name
of the actor involved.
 Place the activities below the actor
performing these activities and then show
how they are connected.
Customer Sales Stockroom

Request Service

Take
Order
Pay Bill
Fill Order

Collect Deliver
Order Order

Modeling a Workflo
State Diagram
 “State diagram represents the pattern of events,
states, and state transitions for a given class”
 It is a graph whose nodes are states and whose
directed arcs are transitions labeled by event
names. If more than one transition leaves a
state, then the first event to occur causes the
corresponding transition to fire. If an event
occurs that has no transition leaving the current
state, then the event is ignored.
 A state diagram describes the behavior of a
single class of objects. Since all instances of a
class have the same behavior, they all share the
same state diagram.
 Events:- An event is something that happens at
a point in time. It can be defined as individual
stimulus from one object to another such as user
depresses left button. They have no time duration.
 Two events that are causally unrelated are said to
be concurrent; they have no effect on each other.
In modeling a system they can occur in any order.
 An event is a one-way transmission of information
from one object to another. It is not like a
subroutine call that returns a value. We group all
the events into event classes and give each event
class a name to indicate common structure and
behavior.
 Some classes of events may be simply signals that
something has occurred, while other classes of
events convey data values or the event attributes.
 Ex-Flight departs( airline, flight number, city),
input string entered( text), digit dialed( digit)
 States:- The attribute values and links
held by an object are called its state . Set of
values are grouped together into a state
according to properties that effect the gross
behavior of the object.
 A state specifies the response of the object to
input events. The response may include an
action or change of state by the object.
 Ex-If a digit is dialed in state ‘dial tone’, the
phone line drops the dial tone and enters state
‘dialing’.
 A state has duration; it occupies an interval of
time.
 A State can be specified by a name and a
description of its purpose. An event sequence
can also be added that leads to the state.
 Scenarios:-
A scenario is a sequence of events that occurs
during one particular execution of a system. It
may include all events in the system or it may
include events generated by certain objects in
the system.
Ex- scenario for using a telephone line is:-
caller lifts receiver
dial tone begins
dial digits
……
phones are disconnected
Caller hangs up
 Event trace diagrams:-
After writing a scenario we identify the sender and
receiver objects of each event. The sequence of
events and the objects exchanging events can both
be shown in an augmented scenario called an
event trace diagram.
Caller Phone line
Callee
caller lifts receiver
dial tone begins
……….
………….
connection broken connection
broken
caller hangs up
 Conditions:- A condition is a Boolean
function of object values which
remains valid over an interval of time.
 Conditions can be used as guards on
transitions. A guarded transition fires
when its event occurs, but only if the
guard condition is true.
 A guard condition is shown as a
Boolean expression in brackets
following the event name.
[ guard condition]
 Operations:- Operations attached to states or
transitions are performed in response to the
corresponding states or events.
 An activity is an operation that takes time to
complete. Activities include continuous operations
and sequential operations. The notation “ do :A”
within a state box indicates that activity A starts on
entry to the state and stops on exit.
 An action is an instantaneous operation. An Action is
associated with an event.
 Actions can also represent internal control
operations, such as setting attributes or generating
other events.
State 1 State 2
Do: activity1 …….
event1 (attribs) [condition1] / action1

notation for state diagrams


 Dynamic model:- The dynamic model consists
of multiple state diagrams, one state
diagram for each class with important
dynamic behavior, and shows the pattern of
activity for an entire system. Steps to
prepare dynamic model:-
 Identify events
 Prepare scenarios of typical interaction

sequences
 Prepare an event trace diagram for each scenario

 Interface formats

 Build a state diagram

 Match events between objects to verify

consistency
Modeling simple
collaboration
 Coming back to the static model, the class
diagram can be used to model simple
collaborations.
 A Collaboration is a society of classes,
interfaces, and other elements that work
together to provide some cooperative
behavior of all the elements.
 For ex- when we model a transaction in a
distributed system, we can’t just stare at a
single class but we consider entire set of
classes that work together.
We use class diagrams to visualize and
specify this set of classes and their
relationships.
Steps to model a collaboration:-
 Identify the mechanism we like to
model. A mechanism represents some
functions that results from the
interaction of a society of classes and
interfaces
 For each functions, identify the classes,

interfaces that participate in this


collaboration. Also identify the
relationships between them.
 Use scenarios to walk through these

things. Add the missing parts


 Specify attributes and operations.
 Figure Path Agent 1 *
shows the Collision Sensor
classes Responsibilities
involved in --seek path 1 1
the --avoid obstacles Driver
mechanism
for moving
the robot
along a path.
1
One abstract 1

class Steering Motor Main Motor


( Motor) and
its two Motor
concrete
children Move( d: direction; s: speed
( steering Stop()
motor and Reset Counter()
main motor). Integer distance()

You might also like