You are on page 1of 46

Software Design & Architecture

Categories of UML Diagrams (3)


Static
Use case diagram
Class diagram

Dynamic

Activity diagram
Sequence diagram
Object diagram
State diagram
Collaboration diagram
3

Implementation

Component diagram
Deployment diagram
4

Sequence Diagram – Dynamic Diagram

 It shows how objects communicate with each other over time


 They are used to model object interaction in time sequence.
 It reflect the ultimate path a particular use case can take for
completion.

 They are used to represent or model the flow of messages,

events and actions between the objects or components of a

system.
5

Sequence Diagram
 It is used primarily to design, document and validate the
architecture, interfaces and logic of the system by describing
the sequence of actions that need to be performed to
complete a task or scenario
 This diagram is a very useful design tools because it provide
a dynamic view of the system behavior which can be difficult
to extract from static diagrams or specifications.
6

Notations in Sequence Diagram


Sequence Diagram has two dimensions:

 Horizontal axis represents Objects of classes involved in class


diagram
 Objects represent the Instance of Class with a format of
Class name: Instance Name
For instance Employee: e
Usually class name is optional
7

Vertical Axis
 Vertical line is draw to represents Life Line of Object (Time
Sequence)
 The lifeline represents the existence of the object at a
particular time
 If the object is created or destroyed during the period of
time then its lifeline starts or stops at the appropriate point;
otherwise it goes from the top to the bottom of the diagram
 If the object is destroyed during the diagram, then its
destruction is marked by a large “X”
8

Activation
 An activation (focus of control) shows the period of time
during which an object is performing an action either directly
or through a message.
 An activation is shown as a tall thin rectangle whose top is
aligned with its initiation time and whose bottom is aligned
with its completion time
9

Graphical Representation
10

Messages

 A message is a communication between objects that conveys


information with the expectation that action will ensure.
 They are used to illustrate communication between different
active objects of a sequence diagram.
 The receipt of a message is normally considered an event.
11

Messages (Cont.)

 A message is represented by an arrow between the life lines


of two objects.
 Self calls are also allowed
 The time required by the receiver object to process the
message is denoted by an activation-box.
 A message is labeled at minimum with the message name.
Arguments and control information (conditions, iteration)
may be included.
12

Return Values
 Optionally indicated using a dashed arrow with a label
indicating the return value.
Don’t model a return value when it is obvious what is being
returned, e.g. getTotal()
Model a return value only when you need to refer to it
elsewhere, e.g. as a parameter passed in another message.
Prefer modeling return values as part of a method
invocation, e.g. ok = isValid()
13

Synchronous Messages
 Nested flow of control, typically implemented as an operation
call.
 The routine that handles the message is completed before
the caller resumes execution.

:A :B

doYouUnderstand()

Caller return
Blocked yes (optional)
14

Asynchronous

 In this type of message the flow is not interrupted and


response is not awaited.
 An asynchronous message is drawn with a half-arrowhead,
that
(one with only one wing instead of two) as shown below
15

Self Message (Recursive)

 We can call this type of message as recursive message i-e


Communication between same message
 A message from an object to itself, the arrow may start
and finish on the same object symbol
16
17

Example with Self Call


18

Example of Sequence Diagram


Sample Sequence Diagram
a : Assembly part : CatalogEntry
: Client
Lifeline
count(part)
getNumber()
Messages
return number

Activation( control returns to the


optional) sender of the message
(optional)
20

Object Creation
• An object may create another object via a
<<create>> message.

Preferred
:A :B :A

<<create>> <<create>>
:B

Constructor
21

Object Creation: Order Entry Example


1 * * 1
Order OrderLine CatalogEntry
quantity: integer
cost: float

: Order : CatalogEntry
: Client Object
creation
add(qty,part)
<<Creates>>
: OrderLine
getCost()

return cost
23

Object Destruction
 An object may destroy another object via a <<destroy>>
message.

 An object may destroy itself.


 Avoid modeling object destruction unless memory
management is critical.

:A :B

<<destroy>>
Object Destruction: Order Entry Example

: Order : OrderLine
: Client

remove(line)
<<destroy>>
X

Object
deletion
25

Guards in Sequence Diagram

 When modeling object interactions, there will be times when


a condition must be met for a message to be sent to the
object.
 Guards behaves likes if statements in the sequence diagram.
 They are used to control the flow
 We place the guard (bars) element above the message line
being guarded and in front of the message name
26

Student Registration in a class


27

Another Example of Guards


Conditional Message: Sequence Diagram

: Order : CatalogEntry
: Client
add(qty,part)
getStockLevel(part)
return s

: OrderLine
[s>=qty] OrderLine(qty,part) getCost()
return cost
29

Combined Fragment

 Combined fragment is an interaction fragment which defines

a combination (expression) of interaction fragments.

 A combined fragment is defined by an interaction

operator and corresponding interaction operands

 For every option there will be corresponding action


30

ALT (UML 2.0) in Sequence Diagram

 Alt keyword represents alternatives to designate a


mutually exclusive choice between two or more message
sequences.
 Alternatives are used to simulate “if then else” situation
as it occur in the programming languages.
 Guards are used to simulate Alternatives in Sequence
diagram
31

Scenario
i. The user will submit the cheque for withdraw.

ii. Bank will check the amount of cheque to be withdrawn.

iii. Bank will check the amount available in the account.

iv. If balance >amount to be withdrawn then debit

transaction is performed and photo of cheque is stored

v. Otherwise the cheque will be returned with message of

insufficient fund.
32
33

Option Combination Fragment

• The option combination fragment 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 without


“else”
34
35

Recurrence (Loop) in Sequence Diagram

 At time repetitions is required to control the flow of the

programs.

 Recurrence are like loops in the programming language.

 Different Versions of UML represents Recurrence

differently, we are using UML 2


36
37
38

Deployment Diagram

Deployment diagrams are used for describing the


hardware components where software components
are deployed
Deployment diagrams are used to describe the static
deployment view of a system
39

Purpose of the Diagram

 The purpose of deployment diagrams can be


described as:
i. Visualize hardware topology of a system.
ii. Describe the hardware components used to
deploy software components.
iii. Describe runtime processing nodes.
40

Target Audience
Deployment diagrams are useful for system engineers.
An efficient deployment diagram is very important
because it controls the following parameters
i. Performance
ii. Scalability
iii. Maintainability
iv. Portability
41

Artifacts in Deployment Diagram

Nodes:
 Nodes are nothing but physical hardwares used to
deploy the application.
 Deployment diagrams consist of nodes and their
relationships.
42

Sample Scenario

The following deployment diagram is a sample to


give an idea of the deployment view of order
management system.
 Monitor
 Modem
 Caching server
 Server
43

Application Flow
• The application is assumed to be a web based
application which is deployed in a clustered
environment using server 1, server 2 and server 3.
The user is connecting to the application using
internet. The control is flowing from the caching
server to the clustered environment.
44

Proposed Component Diagram


45
Deployment diagram

You might also like