Dynamic UML

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 80

OBJECT ORIENTED

METHODOLOGIES

OBJECT DIAGRAM
12/07/16

In the Unified Modeling Language (UML), an object diagram


focuses on some particular set of objects and attributes, and the
links between these instances.
instances
A correlated set of object diagrams provides insight into how an
arbitrary view of a system is expected to evolve over time.
Object diagrams are derived from class diagrams so
object diagrams are dependent upon class diagrams.
Object diagrams represent an instance of a class
diagram.
Object diagrams also represent the static view of a
system but only at a particular moment.
2

MODELING AS UML :STATIC &


DYNAMIC

WEB RESULT DECLARATION


SYSTEM..
12/07/16

We all have experienced such Web based


systems which declares Board Examination
results.

Design level this Software looks perfect but on


the day of exam results declaration, when Thousands
of Students log-in
System Hangs and sometimes crashes
Why.?
We have done appropriate design with Class
Diagram and CRC then Why this Problem and
Failure
At

BECAUSE RESULT DECLARATION


SOFTWARE CHANGES ITS BEHAVIOR
WHEN LARGE USERS
AND STATIC DIAGRAMS (EX. CLASS
DIAGRAM) DOES NOT SHOW THE
BEHAVIORAL CHANGES IN SOFTWARE

DYNAMIC MODELING DIAGRAMS


WERE DEVELOPED
BECAUSE EVERY SOFTWARE
CHANGES ITS BEHAVIOR
DYNAMIC DIAGRAMS SHOWS THE
CHANGES IN SOFTWARE
BEHAVIOR

WHY DYNAMIC MODELING


As the software system continuously changes ( in
states, activities, and collaborations) during life
time, therefore it is needful to model it and
following are grouped in the dynamic modeling
diagrams of UML;

States
Sequences
Collaborations
Activities

These diagram shows how objects interact


dynamically, during execution time of the system.

DYNAMIC MODELING
DIAGRAMS

1.

2.

3.
4.

There are following four diagrams, that represent the


behavioral view of the system and as behavior is a dynamic
phenomenon, the diagrams are also categorized as Dynamic
modeling diagrams
State diagrams describes different states an object
can have during its life cycle, behavior in the states,
events that can change states
Sequence diagrams describes how objects interact
and communicate with each other with the focus on
time
Collaboration diagrams also describes how objects
interact, but the focus is on space
Activity diagrams another way to show interaction
but the focus is on work

STATE CHART DIAGRAMS


Objects have behaviors (methods) and state
(attributes).
(attributes)
The state of an object depends on its current
activity or condition.
A state chart diagram shows the possible
states of the object and the transitions that cause
a change in state.
Captures life cycle of objects, subsystems and
systems.
Tells us the states that an object can have and
what events can change the states.

ACTIVITY DIAGRAMS

The activity diagram is possibly one modeling element


which was not present in any of the predecessors of UML.
No such diagrams were present either in the works of
Booch, Jacobson, or Rumbaugh.
The activity diagram focuses on representing activities or
chunks of processing which may or may not correspond to
the methods of classes.
An activity is a state with an internal action and one or
more outgoing transitions which automatically follow the
termination of the internal activity.
If an activity has more than one outgoing transitions,
then these must be identified through conditions.

10

ACTIVITY DIAGRAMS

An interesting feature of the activity diagrams is the


swim lanes.
Swim lanes enable you to group activities based on who
is performing them.
Thus swim lanes subdivide activities based on the
responsibilities of some components.
The activities in a swim lane can be assigned to some model
elements, e.g. classes or some component, etc.
Activity diagrams are normally employed in business process
modeling. This is carried out during the initial stages of
requirements analysis and specification.
Activity diagrams can be very useful to understand complex
processing activities involving many components. Later these 11
diagrams can be used to develop interaction diagrams which help
to allocate activities (responsibilities) to classes.

ACTIVITY DIAGRAM VS. STATE CHART


DIAGRAM
Both

activity and state chart diagrams model the


dynamic behavior of the system. Activity diagram is
essentially a flowchart showing flow of control from
activity to activity. A state chart diagram shows a state
machine emphasizing the flow of control from state to
state.
An activity diagram is a special case of a state chart
diagram in which all or most of the states are activity
states and all or most of the transitions are triggered by
completion of activities in the source state (An activity
is an ongoing non-atomic execution within a state
12
machine).

ACTIVITY DIAGRAM VS. STATE CHART


DIAGRAM
Activity diagrams may stand alone to visualize, specify, and
document the dynamics of a society of objects or they may be used to
model the flow of control of an operation.
State chart diagrams may be attached
to classes, use cases, or entire systems in order to visualize, specify,
and document the dynamics of an individual object.

13

STATE CHART DIAGRAM

The basic elements of the state chart diagram are as


follows:
Initial state. This is represented as a filled circle.
Final state.
state This is represented by a filled circle inside
a larger circle.
State.
State These are represented by rectangles with
rounded corners.
Transition.
Transition A transition is shown as an arrow between
two states. Normally, the name of the event which
causes the transition is places along side the arrow. A
guard to the transition can also be assigned. A guard
is a Boolean logic condition. The transition can take
place only if the grade evaluates to true.

14

STATE CHART DIAGRAM


Objects have behaviors and state.
The state of an object depends on its current
activity or condition.
A statechart diagram shows the possible states of
the object and the transitions that cause a change in
state.
Let us consider another similar banking application
and model the Login part of an online banking
system.
Logging in consists of entering a valid social
security number and personal id number, then
submitting the information for validation.

15

LOGGING IN BANKING SYSTEM


Logging in can be factored into four nonoverlapping states:
Getting SSN,
II. Getting PIN,
III.Validating, and
IV. Rejecting.
I.

From each state comes a complete set of


transitions that determine the subsequent
state.
16

STATE CHART DIAGRAM FOR BANKING LOGGING IN


SYSTEM

States are rounded rectangles. Transitions are arrows from one state
to another.
Events or conditions that trigger transitions are written beside the
arrows. Our diagram has two self-transition,
self-transition one on Getting SSN and
17
another on Getting PIN.

LOGGING IN SYSTEM
The initial state (black circle) is a dummy to start
the action. Final states are also dummy states
that terminate the action.
The action that occurs as a result of an event or
condition is expressed in the form /action.
While in its Validating state, the object does not
wait for an outside event to trigger a transition.
Instead, it performs an activity. The result of
that activity determines its subsequent state.

18

STATE CHARTS FOR EXAMPLE ATM


SYSTEM

Three of the objects we have identified have behavior


that is sufficiently complex to warrant developing a
State Chart for them. (These are the objects that were
identified as the major controller objects.)
The object representing the machine itself
(responsible for the System Startup and Shutdown
use cases)
Objects representing a customer session (one per
session) (responsible for the Session use case)
Objects representing an individual transaction
(one per transaction) (responsible for the
Transaction use case, use cases for the specific types
of transaction, and Invalid PIN extension).

12/07/16

19

STATE CHART DIAGRAM


12/07/16

20

12/07/16

21

ACTIVITY DIAGRAMS

An activity diagram is essentially a fancy flowchart. Activity


diagrams and statechart diagrams are related. While a statechart
diagram focuses attention on an object undergoing a process (or
on a process as an object), an activity diagram focuses on the flow
of activities involved in a single process. The activity diagram
shows the how those activities depend on one another.

For our example, we used the following process.

"Withdraw money from a bank account through an ATM."

The three involved classes (people, etc.) of the activity are


Customer, ATM, and Bank.

The process begins at the black start circle at the top and ends
at the concentric white/black stop circles at the bottom.
The activities are rounded rectangles.

They may be used to detail situations where parallel


processing may occur in the execution of some activities.
activities

22

OBJECTS AND OBJECT FLOWS

An object flow is a path along which objects or


data can pass. An object is shown as a rectangle.
An object flow is shown as a connector with an
arrowhead denoting the direction the object is
being passed
An object flow must have an object on at least one
of its ends. A shorthand notation for the above
diagram would be to use input and output pins.

12/07/16

23

FORK AND JOIN NODES


Forks and joins have the same notation

12/07/16

either

a horizontal or vertical bar (the orientation is


dependent on whether the control flow is running left
to right or top to bottom).
They indicate the start and end of concurrent
threads of control..

24

JOIN

12/07/16

A join is different from a merge in that the join


synchronizes two inflows and produces a single
outflow.
The outflow from a join cannot execute until all
inflows have been received. A merge passes any
control flows straight through it. If two or more
inflows are received by a merge symbol, the action
pointed to by its outflow is executed two or more
times.

25

DECISION AND MERGE NODES

They can both be named. The control flows coming


away from a decision node will have guard conditions
which will allow control to flow if the guard condition
is met. The following diagram shows use of a decision
node and a merge node.

12/07/16

Decision nodes and merge nodes have the same


notation: a diamond shape.

26

ACTIVITY DIAGRAM
Core symbol is an activity.
An activity is some task which needs to be done.
Each activity can be followed by another activity
(sequencing).
Triggers from the activity may be guarded as in
state diagrams.

DECISION ACTIVITIES
Diamond.
Each

trigger coming from it has a guard.


Synchronisation bar.
or
All triggers from this attach to activities that
can occur in parallel, with no specific
sequence, or concurrently.
The next synchronisation bar closes the
concurrency.
Iteration is represented by a * on the trigger.

ACTIVITY DIAGRAM

29

Shopping

12/07/16

Online

30

12/07/16

31

LAB

12/07/16

Pathology

32

12/07/16

33

AIRPORT SYSTEM
process of getting through an airport to
board a plane. This business process involves
four participants:

12/07/16

The

Passenger, Ticket Agent, Airport

Security, and Boarding Agent.

34

12/07/16

35

DYNAMIC DIAGRAM TYPES


Interaction

Diagrams - Set of objects or roles and the

messages that can be passed among them. illustrate how


objects interact via messages in order to fulfil certain tasks.
Sequence Diagrams - emphasize time ordering
Communication Diagrams - emphasize structural
ordering

State

Diagrams

State

machine consisting of states, transitions, events


and activities of an object

Activity

& Swimlane Diagrams

Emphasize

and show flow of control among objects

Coming up:
Sequence Diagrams

12/07/16

SEQUENCE DIAGRAM

37

SEQUENCE DIAGRAMS

Describe the flow of messages,


events, actions between objects

Show concurrent processes and


activations

Show time sequences that are not easily


depicted in other diagrams

Typically used during analysis and design


to document and understand the logical
flow of your system
Emphasis on time ordering!

THE SEQUENCE DIAGRAM

12/07/16

The sequence diagram is used primarily to show the


interactions between objects in the sequential order that those
interactions occur.
Like the class diagram, developers typically think sequence
diagrams were meant exclusively for them.
However, an organization's business staff can find sequence
diagrams useful to communicate how the business
currently works by showing how various business
objects interact.
Besides documenting an organization's current affairs, a
business-level sequence diagram can be used as a
requirements document to communicate requirements for a
future system implementation.
During the requirements phase of a project, analysts can take
use cases to the next level by providing a more formal level of
refinement. When that occurs, use cases are often refined into
39
one or more sequence diagrams.

USE OF SEQUENCE DIAGRAM


One of the primary uses of sequence diagrams is in the transition
from requirements expressed as use cases to the next and more
formal level of refinement.
refinement
Use cases are often refined into one or more sequence diagrams. In
addition to their use in designing new systems, sequence diagrams
can be used to document how objects in an existing system
currently interact.
This documentation is very useful when transitioning a system to
another person or organization.
sequence diagram shows, as parallel vertical lines
(lifelines), different processes or objects that live
simultaneously, and, as horizontal arrows, the messages
exchanged between them, in the order in which they
40
occur. This allows the specification of simple runtime
scenarios in a graphical manner.

12/07/16

THE NOTATION

12/07/16

A frame element provides a consistent place for a diagram's


label, while providing a graphical boundary for the
diagram.
The frame element is optional in UML diagrams; the
diagram's label is placed in the top left corner called the
frame's "namebox,"

41

USE OF FRAME IN SEQUENCE


DIAGRAM
12/07/16

42

TYPES OF MESSAGE FLOWS


Synchronous: the sender waits until the responder
finishes.
Flat: the sender doesn't wait for anything from the
responder and finishes its' activity; the control is passed
to the responder.
Asynchronous: the sender doesn't wait for anything
from the responder, but it continues its' own activity.

SEQUENCE DIAGRAM

Coming up:
Components

SEQUENCE DIAGRAM

Time Increasing -->

All lines should be horizontal to indicate instantaneous actions.


Additionally if ActivityA happens before ActivityB, ActivityA must
be above activity B

Lower = Later!

Coming up:
Components

COMPONENTS
Objects: aStudent is a specific
instance of the Student class

Specific
Instance of an
Object

Generic (unnamed)
Generic
objects(unnamed)

objects of class type Seminar


and Course

Coming up:
Components

COMPONENTS

execution
lifeline
Coming up:
Components

COMPONENTS

Method call

Return value

Coming up:
Components

ASYNC MESSAGE EXAMPLE

There are problems here what are they?


Synchronous message
Asynchronous
message
Coming
up:
Components:
Guards
Return
message

12/07/16

Student Registration System

50

Student Registration System

12/07/16

51

COLLABORATION AND SEQUENCE


DIAGRAMS:
MAIN
DIFFERENCES

Collaboration diagram illustrates object interactions in


a graph or network format, in which objects can be
placed anywhere on the diagram. It demonstrates how
objects are statically connected.
Sequence diagram illustrates interaction in a kind of
fence format, in which each new object is added to the
right. It generally shows the sequence of events that
occur.

INTERACTION DIAGRAMS: WHEN


AND HOW TO USE THEM?
1.
2.
3.

Identify the system events that are


implied by the use cases.
Make at least one interaction diagram
for each system event.
Make additional interaction diagrams
for alternative courses of events.

12/07/16

54

A SEQUENCE DIAGRAM THAT HAS


INCOMING AND OUTGOING
MESSAGES
the vertical dimension
shows, top down,
12/07/16

the time sequence of messages/calls as


they occur, and the

55
horizontal dimension shows, left to right, the object instances
that the messages are sent to.

AN OBJECT CALLING ITSELF


12/07/16

56

PURPOSE OF A SEQUENCE
DIAGRAM

define event sequences that result in some


desired outcome.
The focus is less on messages themselves and
more on the order in which messages occur;
Most sequence diagrams will communicate
what messages are sent between a system's
objects as well as the order in which they
occur.
12/07/16

It

57

LIFELINES

When drawing a sequence diagram, lifeline notation


elements are placed across the top of the diagram.
Lifelines represent either roles or object instances that
participate in the sequence being modeled. [Note: In
fully modeled systems the objects (instances of classes)
will also be modeled on a system's class diagram.]
Lifelines are drawn as a box with a dashed line
descending from the center of the bottom edge.The
lifeline's name is placed inside the box.

12/07/16

58

MESSAGES
The first message of a sequence diagram always starts at the
top and is typically located on the left side of the diagram for
readability.
Subsequent messages are then added to the diagram slightly
lower then the previous message.

12/07/16

59

COMBINED FRAGMENTS
ALTERNATIVES, OPTIONS, LOOPS
A combined fragment is used to group sets of
messages together to show conditional flow in a
sequence diagram.

are used to designate a mutually


exclusive choice between two or more message
sequences.Alternatives allow the modelling of the
classic "if then else" logic.
Option: is used to model a sequence that, given a
certain condition, will occur; otherwise, the sequence
does not occur. An option is used to model a simple "if
then" statement.
Loops: model a repetitive sequence. They are mostly
used to model for and while loops.

12/07/16

Alternatives:

60

12/07/16

SEQUENCE DIAGRAM ALTERNATIVES

61

SEQUENCE DIAGRAM - OPTIONS


12/07/16

62

SEQUENCE DIAGRAMS - LOOPS


12/07/16

63

SEQUENCE DIAGRAMS
12/07/16

It is, allocating the software functions


youve identified into the set of classes you
discovered during preliminary design.
When you draw sequence diagrams, youre
taking another sweep through the preliminary design, adding in detail.
Use sequence diagrams to drive the detailed
design. But note that we advocate draw-ing
your sequence diagrams in a minimal, quite
specific format

64

SEQUENCE DIAGRAM OF E-MAIL MESSAGE


SEQUENCE
12/07/16

65

Sequence Diagram Notation


(Customercalling onSearc

.
12/07/16

object life
lines)
represent
time

h()on Search Page).

Verbs are turned into msg

66

12/07/16

The objects across the top of the diagram (Customer, Search Page, etc.) are
interacting with each other by passing messages back and forth. The vertical
dotted lines (or object life-lines) represent time, so the process shown in the
diagram begins with the topmost message
(Customercalling onSearch()on Search Page).
The boundary object and entity object icons from robustness diagram.
However, that there are no controller objects on the sequence diagram
(although there could be). This is because when you draw the sequence
diagrams, the controllers (the verbs) are turned into messages on the
boundary and entity objects (the nouns).
Sometimes youll find real controller classes, such as a manager or a
dispatcherclass, and sometimes a framework might tempt you to litter your
design with dozens of tiny controller classes, but as a general rule of
thumb, 80% or so of the controllers from the robustness diagrams can be
implemented as one or more operations on the entity and boundary classes.
The focus of control represents the time that a particular method/function has
control. It starts with the arrow going into the function and finishes when
the
67
function returns.

SEQUENCE DIAGRAMS STRENGTHS AND WEAKNESSES


Strengths:
- they clearly show sequence or time ordering of
messages
- the notation is rather simple
Weaknesses:
- forced to extend to right when adding new
objects, consumes a lot of space

RULES OF THUMB
Rarely

use options

These

constructs complicate a diagram and make


them hard to read/interpret.
Frequently it is better to create multiple simple
diagrams

Create

sequence diagrams for use cases when it


helps clarify and visualize a complex flow

Remember:

the goal of UML is communication


and understanding

SUMMARY
Sequence diagrams model object interactions with an
emphasis on time ordering
Method call lines

Must be horizontal!
Vertical height matters!
Lower equals Later
Label the lines

Lifeline dotted vertical line


Execution bar bar around lifeline when code is
running
Arrows

Synchronous call (youre waiting for a return value) triangle


arrow-head
Asynchronous call (not waiting for a return) open arrow-head
Coming up: In class
Return call dashed line
exercise

COLLABORATION DIAGRAM

12/07/16

A collaboration diagram, also called a communication diagram or


interaction diagram, is an illustration of the relationships and
interactions among software objects in the Unified Modeling
Language (UML).
The concept is more than a decade old although it has been
refined as modeling paradigms have evolved.
A collaboration diagram resembles a flowchart that portrays the
roles, functionality and behavior of individual objects as well as
the overall operation of the system in real time.
Objects are shown as rectangles with naming labels inside. These
labels are preceded by colons and may be underlined. The
relationships between the objects are shown as lines connecting
the rectangles.

71

CONT
messages between objects are shown as
arrows connecting the relevant rectangles along
with labels that define the message sequencing.
Collaboration diagrams are best suited to the
portrayal of simple interactions among relatively
small numbers of objects. As the number of
objects and messages grows, a collaboration
diagram can become difficult to read

12/07/16

The

72

COLLABORATION DIAGRAMS
A

collaboration diagram shows the relationship


between objects and the order of messages
passed between them.

The

objects are listed as icons and arrows


indicate the messages being passed between
them.

The

numbers next to the messages are called


sequence numbers and, as the name suggests,
they show the sequence of the messages as they
are passed between the objects.

COLLABORATION DIAGRAM
AN EXAMPLE

COLLABORATION DIAGRAMS MORE


COMPLEX EXAMPLE

12/07/16

76

COLLABORATION DIAGRAMS STRENGHTS AND


WEAKNESSES

One of the greatest strengths of collaboration diagrams is


their simplicity.
The principal weakness, however, is that although they
are good at describing behavior, they do not define it.
They typically do not show all the iteration and control
that is needed to give an computationally complete
description.

WHERE TO USE INTERACTION


DIAGRAMS?
12/07/16

interaction diagrams are used to describe


dynamic nature of a system.
basic nature of sequence and collaboration
diagram.
The main purposes of both the diagrams are
similar as they are used to capture the dynamic
behaviour of a system. But the specific purposes
are more important to clarify and understood.

78

12/07/16

Sequence diagrams are used to capture the order of


messages flowing from one object to another.
Collaboration diagrams are used to describe the
structural organizations 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 is as a whole.
The interaction diagrams are used when we want to
understand the message flow and the structural
organization.
Now message flow means the sequence of control flow
from one object to another and structural organization
means the visual organization of the elements in a
system.

79

12/07/16

In a brief the following are the usages of interaction


diagrams:
To model flow of control by time sequence.
To model flow of control by structural organizations.
For forward engineering.
For reverse engineering.

80

You might also like