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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

¡CampaignManagergetName()¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listCampaigns():ClientcheckCampaignBudget()* getCampaignDetails():Campaign* getCost()* getCost():AdvertgetOverheads()Figure 8. Illegal sequence diagramoperations, i.e. method calls, while a class diagramsdetermines the following variables on which sequencediagram operates:• for every class, a class variable that takes values<strong>of</strong> sets <strong>of</strong> objects <strong>of</strong> the concept;• for every object <strong>of</strong> a concept, a variable for eachattribute <strong>of</strong> the concept;• for every association, an association variablethat take values <strong>of</strong> sets <strong>of</strong> links (i.e. pairs) betweenobjects <strong>of</strong> the associated classes.2. Due to the inheritance mechanism, the effect <strong>of</strong> a usecase on a variable depends on its current type duringexecution, rather than its originally declared type.3. As in imperative languages, a state <strong>of</strong> a variable is itscurrent value. An object is represented as a finite tuplethat records its identity, current type, and the values <strong>of</strong>its attributes.In summary, a model <strong>of</strong> an OO design is a system S =(α, Φ, Θ, P ) where• P consists <strong>of</strong> a set <strong>of</strong> operations obtained from a number<strong>of</strong> sequence diagrams.• α identifies the variables on which the operations in Poperate and it is determined by the class diagram andthe input and output parameters <strong>of</strong> the methods in thesequence diagram.• The invariant Φ formally models the invariant constraint,such as multiplicities and business rules. Thepair (α, Φ) thus gives the formalization <strong>of</strong> the classmodel.• Θ is a condition to be established when starting up thesystem.5 <strong>Formal</strong> <strong>Semantics</strong> <strong>of</strong> <strong>Sequence</strong> <strong>Diagram</strong>We consider both static and dynamic semantics <strong>of</strong> sequencediagrams. In an abstract syntactic form, a wellformedsequence diagram corresponds to an ordered hierarchicaltree structure. The static semantics <strong>of</strong> a sequencediagram is to check whether it is consistent with the classdiagram declaration. This means that the static semantics isalways dependent on a given class diagram ∆. Meanwhile,the dynamic semantics is defined as a sequence composition<strong>of</strong> the first layer system messages <strong>of</strong> its ordered tree.When a message is executed, it must be consistent with systemstate, i.e., object diagram and the state diagrams <strong>of</strong> therelevant objects.5.1 Static semantics <strong>of</strong> sequence diagramGiven a class diagram ∆, let CN be the set <strong>of</strong> classnames in ∆, AN set <strong>of</strong> association names, Ass the set <strong>of</strong>all associations each <strong>of</strong> which is represented in the form< C 1 , A, C 2 >, where C 1 , C 2 ∈ CN and A ∈ CN, andmethod(C) be the set <strong>of</strong> all the methods <strong>of</strong> class C in ∆.Obviously, for a given messagemsg = (ob i : C i , ob j : C j , g → m(), order)we can define its static semantics as follows.S s [smg]] def= C i ∈ CN ∧ C j ∈ CN∧∃A ∈ CN. < C i , A, C j >∈ Ass ∧ m ∈ Method(C j )The static semantics <strong>of</strong> a sequence diagram is defined asthe conjunction <strong>of</strong> all its messages in the structure tree.5.2 Dynamic <strong>Semantics</strong> <strong>of</strong> MessageExecution <strong>of</strong> a message makes system change from onestate s to another s ′ . Based on Hoare and He’s UnifyingTheories <strong>of</strong> Programming [9], we can define a message actionas first order logic formula on a pair <strong>of</strong> system states(s, s ′ ). Before giving the semantics <strong>of</strong> messages, we introducesome useful auxiliary functions: for states s and s ′ ,• s(C) : the set <strong>of</strong> objects <strong>of</strong> class C in state s.• s(ob): the corresponding state <strong>of</strong> object ob in systemstate s, i.e. the values <strong>of</strong> the attributes <strong>of</strong> ob.6

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

Saved successfully!

Ooh no, something went wrong!