Vous êtes sur la page 1sur 7

UNIT 3 (Interaction Diagrams)

CONTENTS:
3.1 Collaboration Diagrams: Terms and concepts, depicting a message, polymorphism, iterated
messages, use of self in messages.
3.2 Sequence Diagrams: Terms and Concepts, depicting asynchronous message with / without priority,
callback mechanism, broadcast messages.
3.1 Collaboration Diagrams:
3.. Terms an! conce"ts: A collaboration diagram is an interaction diagram that emphasies the
structural organiation of the ob!ects that send and recei"e messages. #raphically, a collaboration diagram
is a collection of "ertices and arcs.
Collaboration diagrams ha"e two features that are useful to distinguish it from se$uence diagrams.
%irst, there is a path. To indicate that how one ob!ect is linked to another, attach path stereotype to far end
of a link. &ath takes e'plicitly any of names such as local, parameter, global, and self.
(econd, there is se$uence number. To indicate time order of a message, each message is prefi'ed with a
number, the number used is increased for each new message in"ol"ed in the flow of control. To show
nesting of messages, )ewey decimal numbering is used that means the messages is numbered 1, the
nested messages in it are numbered with 1.1 and 1.2 etc. The nesting may goes to arbitrary depth.
(ometimes, you can also model more comple' flows in"ol"ing iteration and branching.
An iteration denote a repeated se$uence of messages. To model an iteration, prefi' se$uence number of a
message with an iteration e'pression such as *+i,-1..n.. An iteration indicates the message will be
repeated in accordance to gi"en e'pression.
(imilarly, a condition or branching represents a message whose e'ecution is contingent on the e"aluation
of a /oolean condition. To model a condition, prefi' se$uence number of a message with a condition
clause such as +'01.. The alternate paths of a branch will ha"e the same se$uence number but each path
must be uni$uely distinguishable by a nono"erlapping condition.
The abo"e is an e'ample of collaboration diagram in which first aircraft lands, and during landing,
specific angle is set at left side.
S.HRUSHIKESAVA RAJU Page 1
Fig 3.1.1 : Collaboration Diagram
%or both iteration and branching, 234 doesn5t prescribe the format of e'pression inside the brackets.
&seudo code used should follow synta' of any programming language.
The common use of Collaboration diagrams are,
16 To 3odel flows of control by organiation, 3odeling a flow of control by organiation
emphasies the structural relationships among the instances in the interaction, along with
messages passed. collaboration diagrams do a better !ob of "isualiing comple' iteration and
branching and also "isualiing multiple concurrent flows of control than do se$uence diagrams.
3..# De"icting a message: 3essages are specified on the path associated between the ob!ects. The
directed arrow denote the action performed from sender ob!ect to recei"ing ob!ect. There are two types of
messages which are asynchronous and synchrounous. The differences between them are listed in the
table.
$s%nc&ronous 'essage S%nc&ronous 'essage
(ender doesn5t wait until target ob!ect finishes
e'ecution of the message
(ender ha"e to wait until target ob!ect finishes
e'ecution of the message
Target ob!ect processes many messages at a time Target ob!ect processes only one message at a time
This beha"ior represents multi threaded processor This beha"ior represents single threaded processor
This is denoted using symbol This is denoted using symbol
/y default, the message specified is asynchrounous.
The following is an e'amples. 16 %irst e'ample denote specification of msg1 on 7egister and msg2, msg3,
and msg8 are specified from register to sale, and msg9 is specified from sale to register.
26 (econd denote specific angle is set on left flap and its flow from anAircraft to left%lap.
S.HRUSHIKESAVA RAJU Page 2
36 Third denote depostfunds message flow from fromAccount to toAccount.
86 %ourth denote set4ast:ithdrawalTime message is specified from custAccount to cust.
3..3 (ol%mor"&ism: &oly means many and morphism means forms. An operation or a message e'ists in
many forms. The following diagram illustrate polymorphism in which payment e'ists in many forms such
as for debit and also for credit.
;'ample,
3..3 Iterate! 'essages: An iterated message is a message that can be repeated until loop condition
made false. The following illustrate iterated message.
S.HRUSHIKESAVA RAJU Page 3
The operation or message titled scale<=>o.6 may be
applied to any polygon form. The polygon may be
s$uare, pentagon, and any other ha"ing more than 2
sides.
3..) Use o* sel* in messages: (elf message is a path stereo typed with ??self00. This is a message sent
from one ob!ect to same ob!ect itself or ob!ect of same class. The following illustrate self message,
E+am"le:
S.HRUSHIKESAVA RAJU Page 4
Loop frame sho!" #e
$i$!e" a$ $op !ef$ %or&er is
!oop' a&" arro(s (i$hi& i$
"e&o$e messages $ha$
sho!" #e repea$e" &$i!
$here are &o i$ems $o )isi$.
*his "e&o$e
%o&$i&g %os$ of
$o$a! i$ems
i&%!"e" i& $he
#i!!. Ea%h i$em
%os$ is %omp$e"
a!o&g (i$h
+a&$i$,.
*his "e&o$e opera$io& s%a!i&g o&
a se$ of po!,go&s. A #o- o&
A&o$her #o- "e&o$e m!$ip!e
o#.e%$s. *his ses a forma$ /:
message01ame2argme&$s3
*his me$ho" se 4rs$ argme&$ i&
$he message is of 5e,(or" se!f.
E+am"le#:
3.2 Sequence Diagrams:
3.#. Terms an! Conce"ts: (e$uence diagrams emphasie the time ordering of messages. @n drawing
se$uence diagrams, first place the ob!ects that participate in the interaction at the top of the diagram
across ABa'is. Cb!ects are listed at the top of the diagram in which the ob!ect that initiate the interaction is
placed at left, and more subordinate ob!ects on right increasingly. >e't, place the messages between the
ob!ects that send and recei"e along DBa'is in order of time from top to bottom. (e$uence diagrams are
distinguished from collaboration diagrams in two ways.
%irst, there is ob!ect life line. An ob!ect life line is the "ertical dashed line that represents e'istence of an
ob!ect o"er a period of time. Cb!ects are created during the interaction. Their lifelines start with the
receipt of the message stereotyped as create. Cb!ects are also destroyed with message stereotyped as
destroy.
(econd, there is focus of control. The focus of control is a tall, thin rectangle that shows the period of
time during which an ob!ect is performing an action through directly or subordinate procedure. The top of
rectangle is aligned with the start of the action and bottom denotes completion.
The common uses of (e$uence diagrams are,
13 To model flows of control by time ordering, 3odeling a flow of control by time ordering
emphasies the passing of messages as they unfold o"er time, which is a particular useful way to
S.HRUSHIKESAVA RAJU Page 6
*his me$ho" se re%ei)i&g o#.e%$
as pre4-e" (i$h 5e,(or" se!f.
I& $he se+e&%e "iagram'
Regis$er performs 7oA 4rs$'
$he& se%o&"' "o8' $he&
$hir" "o9' a&" For$h "o7.
S,&%hro&os message
spe%i4e" (i$h s,m#o! arro(
(i$h 4!!e" hea".
"isualie dynamic beha"ior in the conte't of a use case scenario. (e$uence diagrams do a better
!ob of "isualiing simple iterations and branching than do collaboration diagrams.
3.#. De"icting as%nc&ronous message ,it& - ,it&out "riorit%: @f some message is considered
important to do first, and other messages ne't to do, then priority concept is useful. Cne way to deal with
asynchronous message is to $ueue them so that the one message in the $ueue is processed at a time.
)epicting message with priority is re$uired if ob!ects doesn5t implement threading but the system is
concurrent, then $ueue the messages for later processing using priorities.
The following are diagrams illustrating asynchronous messages in the se$uence diagrams.
;'ample1,
3.#.# Callbac. mec&anism: This in"ol"e if ob!ect C1 interested in e"ent e that occur in Cb!ect C2,
(ender C1 sends a message to C2 and continues e'ecution. :hen the e"ent e occurs in C2, C2 will calls
C1 to e'ecute. The following illustrate the call back mechanism.
3.#.3 /roa!cast 'essages: As like iterated messages, /roadcast means a message is sent to many
ob!ects. >o references are re$uired for this broadcasting mechanism. /roadcasting means sending a
message to all ob!ects in the system. /roadcast message is stereotyped with 00broa!cast11 on the path.
S.HRUSHIKESAVA RAJU Page :
*he o#.e%$ a%1 gi)e $he a&g!e ao
$ha$ i$ se$s a&g!e $o $he !ef$F!ap a&"
a!so $o $he righ$F!aps i& or"er.
*he o#.e%$ ;1 se&"s a message $o
"ra(8$$o& o#.e%$ a&" is i&$eres$e"
i& $he e)e&$s $ha$ o%%r i& $he
#$$o&. <he& ser i&$era%$s (i$h
#$$o&' re%ei)er o#.e%$ "ra(8$$o&
%a!!s #a%5 se&"er o#.e%$ app.
;'ample1,
;'ample2,
S.HRUSHIKESAVA RAJU Page =
I& se&"i&g a message $o a
spe%i4% %a$egor, of o#.e%$s
$ha$ is %a!!e" &arro(
%as$i&g.
i$ is sho(& i&ea-mp!e2.

Vous aimerez peut-être aussi