版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、<p><b> 中文2270字</b></p><p> UML2.0 Sequence Diagram Combined fragments</p><p> The diagram's purpose</p><p> The sequence diagram is used primarily to show
2、the interactions between objects in the sequential order that those interactions occur. Much like the class diagram, developers typically think sequence diagrams were meant exclusively for them. However, an organization&
3、#39;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 busine
4、ss-level sequence dia</p><p> An organization's technical staff can find sequence diagrams useful in documenting how a future system should behave. During the design phase, architects and developers can
5、 use the diagram to force out the system's object interactions, thus fleshing out overall system design. </p><p> One of the primary uses of sequence diagrams is in the transition from requirements expr
6、essed as use cases to the next and more formal level of 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 docu
7、ment how objects in an existing (call it "legacy") system currently interact. This documentation is very useful when transitioning a system to another person or organization. </p><p> The notation
8、 </p><p> Since this is the first article in my UML diagram series that is based on UML 2, we need to first discuss an addition to the notation in UML 2 diagrams, namely a notation element called a frame. T
9、he frame element is used as a basis for many other diagram elements in UML 2, but the first place most people will encounter a frame element is as the graphical boundary of a diagram. A frame element provides a consisten
10、t place for a diagram's label, while providing a graphical boundary for the diagram.</p><p> In most sequence diagrams, however, the UML 1.x "in-line" guard is not sufficient to handle the log
11、ic required for a sequence being modeled. This lack of functionality was a problem in UML 1.x. UML 2 has addressed this problem by removing the "in-line" guard and adding a notation element called a Combined Fr
12、agment. A combined fragment is used to group sets of messages together to show conditional flow in a sequence diagram. The UML 2 specification identifies 11 interaction types for combined fra</p><p> Altern
13、atives</p><p> Alternatives are used to designate a mutually exclusive choice between two or more message sequences. 3 Alternatives allow the modeling of the classic "if then else" logic (e.g., if
14、 I buy three items, then I get 20% off my purchase; else I get 10% off my purchase).</p><p> As you will notice in Figure 8, an alternative combination fragment element is drawn using a frame. The word &quo
15、t;alt" is placed inside the frame's namebox. The larger rectangle is then divided into what UML 2 calls operands. 4 Operands are separated by a dashed line. Each operand is given a guard to test against, and thi
16、s guard is placed towards the top left section of the operand on top of a lifeline. 5 If an operand's guard equates to "true," then that operand is the operand to follow.</p><p> Figure 8: A s
17、equence diagram fragment that contains an alternative combination fragment</p><p> As an example to show how an alternative combination fragment is read, Figure 8 shows the sequence starting at the top, wit
18、h the bank object getting the check's amount and the account's balance. At this point in the sequence the alternative combination fragment takes over. Because of the guard "[balance >= amount]," if t
19、he account's balance is greater than or equal to the amount, then the sequence continues with the bank object sending the addDebitTransaction and storePhotoOfCheck messages to th</p><p> Alternative com
20、bination fragments are not limited to simple "if then else" tests. There can be as many alternative paths as are needed. If more alternatives are needed, all you must do is add an operand to the rectangle with
21、that sequence's guard and messages. </p><p><b> Option</b></p><p> The option combination fragment is used to model a sequence that, given a certain condition, will occur; othe
22、rwise, the sequence does not occur. An option is used to model a simple "if then" statement (i.e., if there are fewer than five donuts on the shelf, then make two dozen more donuts).</p><p> The o
23、ption combination fragment notation is similar to the alternation combination fragment, except that it only has one operand and there never can be an "else" guard (it just does not make sense here). To draw an
24、option combination you draw a frame. The text "opt" is placed inside the frame's namebox, and in the frame's content area the option's guard is placed towards the top left corner on top of a lifelin
25、e. Then the option's sequence of messages is placed in the remainder of the frame's con</p><p> Figure 9: A sequence diagram fragment that includes an option combination fragment</p><p>
26、; Reading an option combination fragment is easy. Figure 9 is a reworking of the sequence diagram fragment in Figure 7, but this time it uses an option combination fragment because more messages need to be sent if the s
27、tudent's past due balance is equal to zero. According to the sequence diagram in Figure 9, if a student's past due balance equals zero, then the addStudent, getCostOfClass, and chargeForClass messages are sent. I
28、f the student's past due balance does not equal zero, then the sequence</p><p> The example Figure 9 sequence diagram fragment includes a guard for the option; however, the guard is not a required eleme
29、nt. In high-level, abstract sequence diagrams you might not want to specify the condition of the option. You may simply want to indicate that the fragment is optional.</p><p><b> Loops</b></p
30、><p> Occasionally you will need to model a repetitive sequence. In UML 2, modeling a repeating sequence has been improved with the addition of the loop combination fragment. </p><p> The loop co
31、mbination fragment is very similar in appearance to the option combination fragment. You draw a frame, and in the frame's namebox the text "loop" is placed. Inside the frame's content area the loop'
32、s guard 6 is placed towards the top left corner, on top of a lifeline. Then the loop's sequence of messages is placed in the remainder of the frame's content area. In a loop, a guard can have two special conditio
33、ns tested against in addition to the standard Boolean test. The special guard c</p><p> Figure 10: An example sequence diagram with a loop combination fragment</p><p> The loop shown in Figure
34、 10 executes until the reportsEnu object's hasAnotherReport message returns false. The loop in this sequence diagram uses a Boolean test to verify if the loop sequence should be run. To read this diagram, you start a
35、t the top, as normal. When you get to the loop combination fragment a test is done to see if the value hasAnotherReport equals true. If the hasAnotherReport value equals true, then the sequence goes into the loop fragmen
36、t. You can then follow the messages in t</p><p> UML 2.0 序列圖組合碎片</p><p><b> 圖的目的</b></p><p> 序列圖主要用于按照交互發(fā)生的一系列順序,顯示對(duì)象之間的這些交互。很象類圖,開發(fā)者一般認(rèn)為序列圖只對(duì)他們有意義。然而,一個(gè)組織的業(yè)務(wù)人員會(huì)發(fā)現(xiàn),序列
37、圖顯示不同的業(yè)務(wù)對(duì)象如何交互,對(duì)于交流當(dāng)前業(yè)務(wù)如何進(jìn)行很有用。除記錄組織的當(dāng)前事件外,一個(gè)業(yè)務(wù)級(jí)的序列圖能被當(dāng)作一個(gè)需求文件使用,為實(shí)現(xiàn)一個(gè)未來(lái)系統(tǒng)傳遞需求。在項(xiàng)目的需求階段,分析師能通過提供一個(gè)更加正式層次的表達(dá),把用例帶入下一層次。那種情況下,用例常常被細(xì)化為一個(gè)或者更多的序列圖。</p><p> 組織的技術(shù)人員能發(fā)現(xiàn),序列圖在記錄一個(gè)未來(lái)系統(tǒng)的行為應(yīng)該如何表現(xiàn)中,非常有用。在設(shè)計(jì)階段,架構(gòu)師和開發(fā)者能使
38、用圖,挖掘出系統(tǒng)對(duì)象間的交互,這樣充實(shí)整個(gè)系統(tǒng)設(shè)計(jì)。</p><p> 序列圖的主要用途之一,是把用例表達(dá)的需求,轉(zhuǎn)化為進(jìn)一步、更加正式層次的精細(xì)表達(dá)。用例常常被細(xì)化為一個(gè)或者更多的序列圖。序列圖除了在設(shè)計(jì)新系統(tǒng)方面的用途外,它們還能用來(lái)記錄一個(gè)存在系統(tǒng)(稱它為“遺產(chǎn)”)的對(duì)象現(xiàn)在如何交互。當(dāng)把這個(gè)系統(tǒng)移交給另一個(gè)人或組織時(shí),這個(gè)文檔很有用。</p><p><b> 符號(hào)&
39、lt;/b></p><p> 既然這是我基于 UML 2的 UML 圖系列文章的第一篇,我們需要首先討論對(duì) UML 2 圖符號(hào)的一個(gè)補(bǔ)充,即一個(gè)叫做框架的符號(hào)元件。在 UML 2中,框架元件用于作為許多其他的圖元件的一個(gè)基礎(chǔ),但是大多數(shù)人第一次接觸框架元件的情況,是作為圖的圖形化邊界。當(dāng)為圖提供圖形化邊界時(shí),一個(gè)框架元件為圖的標(biāo)簽提供一致的位置。在 UML 圖中框架元件是可選擇的;就如你能在圖 1 和
40、2 中見到的,圖的標(biāo)簽被放在左上角,在我將調(diào)用框架的“namebox”中,一種卷角長(zhǎng)方形,而且實(shí)際的 UML 圖在較大的封閉長(zhǎng)方形內(nèi)部定義。</p><p> 在大多數(shù)的序列圖中,UML 1.x“in-line”約束不足以處理一個(gè)建模序列的必需邏輯。這個(gè)功能缺失是 UML 1.x 的一個(gè)問題。UML 2 已經(jīng)通過去掉“in-line”約束,增加一個(gè)叫做組合碎片的符號(hào)元件,解決了這一個(gè)問題。一個(gè)組合碎片用來(lái)把一套
41、消息組合在一起,在一個(gè)序列圖中顯示條件分支。UML 2 規(guī)范指明了組合碎片的 11 種交互類型。</p><p><b> 變體</b></p><p> 變體用來(lái)指明在兩個(gè)或更多的消息序列之間的、互斥的選擇。 3 變體支持經(jīng)典</p><p> “if then else”邏輯的建模(舉例來(lái)說(shuō),如果 我買三個(gè),然后 我得到 我購(gòu)買的20
42、% 折扣;否則 我得到我購(gòu)買的 10% 折扣)。就如你將會(huì)在圖 8 中注意到的,一個(gè)變體的組合碎片元件使用框架來(lái)畫。單詞“alt”放置在框架的namebox里。然后較大的長(zhǎng)方形分為 UML 2 所稱的操作元。 4 操作元被虛線分開。每個(gè)操作元有一個(gè)約束進(jìn)行測(cè)試,而這個(gè)約束被放置在生命線頂端的操作元的左上部。 5 如果操作元的約束等于“true”,然后那個(gè)操作元是要執(zhí)行的操作元。</p><p> 圖 8:包含變
43、體組合碎片的一個(gè)序列圖片段</p><p> 圖 8作為一個(gè)變體的組合碎片如何閱讀的例子,顯示序列從頂部開始,即bank對(duì)象獲取支票金額和帳戶結(jié)余。此時(shí),序列圖中的變體組合碎片接管。因?yàn)榧s束“[balance >= amount]”,如果余額超過或等于金額,然后順序進(jìn)行bank對(duì)象傳遞 addDebitTransaction 和 storePhotoOfCheck 消息給account對(duì)象。然而,如果余額
44、不是超過或等于金額,然后順序的過程就是bank傳遞addInsuffientFundFee 和 noteReturnedCheck 消息給account對(duì)象,returnCheck 消息給它自身。因?yàn)椤癳lse”約束,當(dāng)余額不大于或者等于金額時(shí),第二個(gè)序列被調(diào)用。在變體的組合碎片中,不需要“else”約束;而如果一個(gè)操作元,在它上面沒有一個(gè)明確的約束,那么將假定“else”約束。</p><p> 變體的組合碎
45、片沒被限制在簡(jiǎn)單的“if then else”驗(yàn)證??赡苄枰罅康淖凅w路徑。 如果需要較多的變體方案,你一定要做的全部工作就是把一個(gè)操作元加入有序列約束和消息的長(zhǎng)方形中。 </p><p><b> 選擇項(xiàng)</b></p><p> 選擇項(xiàng)組合碎片用來(lái)為序列建模,這些序列給予一個(gè)特定條件,將會(huì)發(fā)生的;</p><p> 或者,序列不發(fā)生。
46、一個(gè)選擇項(xiàng)用來(lái)為簡(jiǎn)單的“if then”表達(dá)式建模。(例如,如果架上的圈餅少于五個(gè),那么另外做兩打圈餅)。</p><p> 選擇項(xiàng)組合碎片符號(hào)與變體組合碎片類似,除了它只有一個(gè)操作元并且永不能有“else”約束以外(它就是如此,沒有理由)。要畫選擇項(xiàng)組合,你畫一個(gè)框架。文字“opt”是被放置在框架的 namebox 里的文本,在框架的內(nèi)容區(qū),選擇項(xiàng)的約束被放置在生命線頂端上的左上角。 然后選擇項(xiàng)的消息序列被放
47、在框架的內(nèi)容區(qū)的其余位置內(nèi)。這些元件如圖 9 所示。</p><p> 圖 9:包括選擇項(xiàng)組合碎片的一個(gè)序列圖片段</p><p> 閱讀選擇項(xiàng)組合碎片很容易。圖 9 是圖 7 的序列圖片段的再加工,但是這次它使用一個(gè)選擇項(xiàng)組合碎片,因?yàn)槿绻鸖tudent的逾期平衡等于0,需要傳遞更多的消息。按照?qǐng)D 9 的序列圖,如果Student的逾期平衡等于零,然后傳遞addStudent,get
48、CostOfClass和chargeForClass消息。如果Student的逾期平衡不等于零,那么在選擇項(xiàng)組合碎片中,序列不傳遞任何一個(gè)消息。</p><p> 例子圖 9的序列圖片段包括一個(gè)選擇項(xiàng)約束;然而,約束不是一個(gè)必需的元件。在高層次、抽象的序列圖中,你可能不想敘述選擇項(xiàng)的條件。你可能只是想要指出片段是可選擇的。</p><p><b> 循環(huán)</b>&
49、lt;/p><p> 有時(shí)候你將會(huì)需要為一個(gè)重復(fù)的序列建模。在 UML 2 中,為一個(gè)重復(fù)的序列建模已經(jīng)改良,附加了循環(huán)組合碎片。循環(huán)組合碎片表面非常類似選擇項(xiàng)組合碎片。你畫一個(gè)框架,在框架的 namebox 中放置文本“l(fā)oop”。在框架的內(nèi)容區(qū)中,一個(gè)生命線的頂部,循環(huán)約束 6 被放置在左上角。然后循環(huán)的消息序列被放在框架內(nèi)容區(qū)的其余部分中。在一個(gè)循環(huán)中,除了標(biāo)準(zhǔn)的布爾測(cè)試外,一個(gè)約束能測(cè)試二個(gè)特定的條件式。特
50、定的約束條件式是寫作“minint = [the number]”(例如,“minint = 1”)的最小循環(huán)次數(shù),和寫作“maxint = [the number]”(例如,“maxint = 5”)的最大循環(huán)次數(shù)。通過最小循環(huán)檢驗(yàn),循環(huán)必須運(yùn)行至少指定次數(shù),而循環(huán)執(zhí)行次數(shù)不能達(dá)到約束指定的最大循環(huán)次數(shù)。</p><p> 圖 10:循環(huán)組合碎片的一個(gè)序列圖例子</p><p> 在
51、圖 10 中顯示的循環(huán)運(yùn)行,直到 reportsEnu 對(duì)象的 hasAnotherReport 消息返回false。如果循環(huán)序列應(yīng)該運(yùn)行,這個(gè)序列圖的循環(huán)使用一個(gè)布爾測(cè)試確認(rèn)。為了閱讀這個(gè)圖,你和平常一樣,從頂部開始。當(dāng)你到達(dá)循環(huán)組合碎片,做一個(gè)測(cè)試,看看值 hasAnotherReport 是否等于true。如果 hasAnotherReport 值等于true,于是序列進(jìn)入循環(huán)片斷。然后你能和正常情況一樣,在序列圖中跟蹤循環(huán)的消息
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫(kù)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- uml序列圖編寫規(guī)范
- UML類圖與序列圖的自動(dòng)生成.pdf
- uml2.0序列圖到事件確定有限自動(dòng)機(jī)轉(zhuǎn)換的研究
- 基于UML序列圖模型的軟件測(cè)試研究.pdf
- 基于UML序列圖的測(cè)試方法研究與工具實(shí)現(xiàn).pdf
- rational rose順序圖(序列圖)的建模步驟
- 序列圖像的接圖實(shí)現(xiàn).pdf
- 超聲序列圖象的特征提取
- 多視點(diǎn)序列圖的視差校準(zhǔn).pdf
- 基于序列圖像的全景圖生成研究.pdf
- 序列圖像人臉檢測(cè)研究.pdf
- 序列圖像斑點(diǎn)的檢測(cè).pdf
- 基于序列圖像的人頭定位.pdf
- 組合機(jī)床-外文翻譯
- 基于時(shí)間屬性序列圖的運(yùn)行驗(yàn)證技術(shù)研究.pdf
- 序列圖像配準(zhǔn)方法研究.pdf
- 外文翻譯--組合機(jī)床
- 組合鏜床外文翻譯
- 基于uml2.0圖的cbd軟件集成測(cè)試方法研究
- CT腫瘤序列圖像的分割.pdf
評(píng)論
0/150
提交評(píng)論