10.07.2015 Views

A Formal Semantics of UML Sequence Diagram - UNU-IIST - United ...

A Formal Semantics of UML Sequence Diagram - UNU-IIST - United ...

A Formal Semantics of UML Sequence Diagram - UNU-IIST - United ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

and edges represent links and passing messages. Since asequence diagram is defined as a sequence <strong>of</strong> messages, weshould give formal definition <strong>of</strong> messages.Definition 1 A message is a tuple:wheremsg = (ob i : C i , ob j : C j , action, order)• ob i is the source object <strong>of</strong> the message with class typeC i , <strong>of</strong> course the source <strong>of</strong> message can also be anactor.• ob j is the target object <strong>of</strong> the message with class typeC j .• action is a guarded method call <strong>of</strong> the form g → act ,where g is a Boolean expression <strong>of</strong> attributes <strong>of</strong> sourceobject ob i , and possibly public variables, and actionis either a command without method calls (an internalaction) or a method call ob j .m().• order is the order number <strong>of</strong> the message in the correspondingsequence diagram structure tree. All the ordernumbers <strong>of</strong> messages in the sequence diagram constructa partial order. The order number <strong>of</strong> a messageis given according to its position in the tree. The rootnode is corresponding to the starting object or actor <strong>of</strong>a sequence diagram. Then the first layer branches withorder number is 1, 2, , 3, · · · , n. From the u-th nodeob u <strong>of</strong> first layer object nodes, perhaps there are mnodes. The corresponding order numbers <strong>of</strong> branchesare u.1, u.2, · · · , u.m. The u.v is the v-th branchesfrom the node object ob u . Given the sequence diagramexample in Figure 2, the corresponding structure treewith ordered messages is shown in Figure 7.We now look at how composite diagrams can be constructedfrom basic diagrams by using programming language-likeconstructs.obi : Cig -> m()obj : Cjg -> m()Figure 3. Basic activation notationobi : Ciobj : Cj• The activation notation <strong>of</strong> a basic message in sequencediagram is shown in Figure 3.• The iterative notation <strong>of</strong> messages is shown in Figure4. The corresponding ordered tree can be constructedin the figure.• The special messages such as create object anddestroy are shown in Figure 5.• And the branching choice case <strong>of</strong> messages can bedealt as shown in Figure 6.obi : Cig -> m()u.v.1: * g1 -> n1()u.v : g -> m()obk : Ckobj : Cjobi : Ci* g1 -> n1()g2 -> n2()obj : Cjobk : Ckobk : Cku.v.2: g2 -> n2()Figure 4. Iteration notationA complicate sequence diagram can be constructed byabove basic notations. For sequence diagram <strong>of</strong> Figure 2,we can easily derive its corresponding message orderedstructure tree as shown in Figure 7.The ordered structure tree presents the hierarchical relationshipsamong the messages. And the execution <strong>of</strong> messages(i.e. execution <strong>of</strong> the method represented by the message)in the sequence diagram must follow the traversingrule <strong>of</strong> first root then son trees from left to right. For onethread sequence diagram, there is only one token to denotecontrol right <strong>of</strong> invoking message. In the beginning <strong>of</strong> anexecution <strong>of</strong> the sequence diagram, the token is in the actor’shand. When the source <strong>of</strong> message wants to invokea message, the source object or actor must hold the token.When the message is invoked, the token should be passedthe target <strong>of</strong> message. The source <strong>of</strong> message will wait untilthe target return the token, it can invoke another messageor return the token to the previous source which invoked itbefore. We consider that the execution <strong>of</strong> a sequence diagramfrom the start to termination is the process <strong>of</strong> the token4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!