Must know something of everything and everything of something!
Interaction Diagrams
上一篇 /
下一篇 2007-03-30 15:27:33
/ 个人分类:Testing
Interaction Diagrams
o`n`1[/?we0R K)E*Dx gV|e0Interaction diagrams model the behavīor of use cases by describing the way groups of objects interact to complete the task. The two kinds of interaction diagrams aresequenceandcollaborationdiagrams. This example is only meant as an introduction to the UML and interaction diagrams. If you would like to learn more see theResourcespage for a list of more detailed resources on UML.
M$Dz3V
kp:w0When to Use: Interaction Diagrams
-m3zhm:__B"v;E0Interaction diagrams are used when you want to model the behavīor of several objects in a use case. They demonstrate how the objects collaborate for the behavīor. Interaction diagrams do not give a in depth representation of the behavīor. If you want to see what a specific object is doing for several use cases use astate diagram. To see a particular behavīor over many use cases or threads use anactivity diagrams.1
/m4y3?:Af4Z0
How to Draw: Interaction Diagrams
-Vgp c0C
\
z6B"{0Sequence diagrams, collaboration diagrams, or both diagrams can be used to demonstrate the interaction of objects in a use case. Sequence diagrams generally show the sequence of events that occur. Collaboration diagrams demonstrate how objects are statically connected. Both diagrams are relatively simple to draw and contain similar elements.1
^6{&JJ"s6_O7CBw0/hmUsn4J
E&X0Sequence diagrams:
/~;{'El)|-e` P051Testing软件测试网NJ(jrd4XSequence diagrams demonstrate the behavīor of objects in a use case by describing the objects and the messages they pass. the diagrams are read left to right and descending. The example below shows an object of class 1 start the behavīor by sending a message to an object of class 2. Messages pass between the different objects until the object of class 1 receives the final message.
h]~6E+nIU01J4F*MsV"K1eM0
@g ba
Et+IT.bFe0
WZJ{bf0Below is a slightly more complex example. The light bluevertical rectanglesthe objects activation while the green verticaldashed linesrepresent the life of the object. The greenvertical rectanglesrepresent when a particular object has control. Therepresents when the object is destroyed. This diagrams also shows conditions for messages to be sent to other object. The condition is listed between brackets next to the message. For example, a [condition] has to be met before the object of class 2 can send a message() to the object of class 3.
[r\4Q'{7`0T1O051Testing软件测试网Gy1M5y:w_D)e"q51Testing软件测试网2T'U5mR'|U
51Testing软件测试网(`yG:NbgThe next diagram shows the beginning of a sequence diagram for placing an order. The object an Order Entry Window is created and sends a message to an Order object to prepare the order. Notice the the names of the objects are followed by a colon. The names of the classes the objects belong to do not have to be listed. However the colon is required to denote that it is the name of an object following the objectName:className naming system.51Testing软件测试网JHm:JJ8@
3Ok}&Ii
Z0Next the Order object checks to see if the item is in stock and if the [InStock] condition is met it sends a message to create an new Delivery Item object.
;JvXV-e$V0o+Ze#o
R0Wl*zW+_/PC"dx0
]$XY-@
j
{0
5f)VH _,FS0The next diagrams adds another conditional message to the Order object. If the item is [OutOfStock] it sends a message back to the Order Entry Window object stating that the object is out of stack.
P&S0~T+b)c0e6GZ2{D5L
c051Testing软件测试网6H3O/Cqz1G5}J7lV W
51Testing软件测试网Cu]z(@^x
LMThis simple diagram shows the sequence that messages are passed between objects to complete a use case for ordering an item.
Z_)Rxe,Tb0
51Testing软件测试网'WM(C T\~3zICollaboration diagrams:51Testing软件测试网%}&iW!t6d2zE[
51Testing软件测试网8gUp+|:Lh
fCollaboration diagrams are also relatively easy to draw. They show 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. As the name suggests, they show the sequence of the messages as they are passed between the objects. There are many acceptable sequence numbering schemes in UML. A simple 1, 2, 3... format can be used, as the example below shows, or for more detailed and complex diagrams a 1, 1.1 ,1.2, 1.2.1... scheme can be used. 51Testing软件测试网n(F c*F?B
B.t3X\|
51Testing软件测试网
J$Kzq U#I:]*?'V.l]8P+ds:_6miO0
51Testing软件测试网 l*~x D%n5aThe example below shows a simple collaboration diagram for the placing an order use case. This time the names of the objects appear after the colon, such as :Order Entry Window following the objectName:className naming convention. This time the class name is shown to demonstrate that all of objects of that class will behave the same way.
jQB
Wc7L,Z8e051Testing软件测试网^CX{ c cC#}51Testing软件测试网8~ ?]DZ/Q#|7hrv
收藏
举报
TAG:
UML