Must know something of everything and everything of something!

Interaction Diagrams

上一篇 / 下一篇  2007-03-30 15:27:33 / 个人分类:Testing

Interaction Diagrams51Testing软件测试网/}_"K;VwW"^

kF?'d_ d0Interaction 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.51Testing软件测试网md8Y7Q&| s.?y R

When to Use: Interaction Diagrams

51Testing软件测试网s!{wj$r v%V n

Interaction 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.151Testing软件测试网9C:U+h @_ [

How to Draw: Interaction Diagrams

6nT6|%QX$Wt i0Sequence 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.151Testing软件测试网%?C8P0ka

51Testing软件测试网0s*Q'Z?[/xT$ey

Sequence diagrams:51Testing软件测试网!a8H p'D C/L

51Testing软件测试网r5K^5`k,BP

Sequence 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.51Testing软件测试网tyC5D&F$[i O

51Testing软件测试网+FX]4l K9z"|l!XZ

51Testing软件测试网 \:E)zT]&vN(|xo

rL([O{gcuR0Below 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.  

#k0bRcmU1u,K0

8nF'b:q6{9mHyL051Testing软件测试网/e5TSE7S'\+o'T

D|%z:H9|S9a,k JS4@0The 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.

Y5},BKb}W+O0

6^1U0w2R4C3y7u0Next 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.51Testing软件测试网!`Xn^4B c?.L

51Testing软件测试网 uU-rh*a j6nb

[[t] WTI0Y+W0
51Testing软件测试网$`-hGgO4r:qN

The 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.  51Testing软件测试网UCfxs-F

51Testing软件测试网IE7[3^JQi

51Testing软件测试网_b[&b2H[6\

h"Y ^.R[@'z3ML!Pf Z0This simple diagram shows the sequence that messages are passed between objects to complete a use case for ordering an item.51Testing软件测试网&I(O$[7DR

)]B4e;N}#T0Collaboration diagrams:51Testing软件测试网VW#Ie^.wP

p4a!tJ9y9\(|l0Collaboration 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软件测试网&` R%h*k9r_

51Testing软件测试网%zbR`6LGlc\

51Testing软件测试网IHyt)]'@

S+I9NL+r\~)a3S E0The 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.

p W[ D/A^V|#d!h0
51Testing软件测试网}!di&XPGLVs_

51Testing软件测试网q7v*{~ eZZ2V


相关阅读:

TAG: UML

 

评分:0

我来说两句

日历

« 2024-04-30  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 76967
  • 日志数: 93
  • 建立时间: 2007-03-22
  • 更新时间: 2007-12-31

RSS订阅

Open Toolbar