software design modelling and analysis in uml
play

Software Design, Modelling and Analysis in UML Lecture 05: Object - PDF document

Software Design, Modelling and Analysis in UML Lecture 05: Object Diagrams, OCL Consistency 2013-11-06 05 2013-11-06 main Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universit at Freiburg, Germany Contents


  1. Software Design, Modelling and Analysis in UML Lecture 05: Object Diagrams, OCL Consistency 2013-11-06 – 05 – 2013-11-06 – main – Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universit¨ at Freiburg, Germany Contents & Goals Last Lecture: • OCL Semantics This Lecture: • Educational Objectives: Capabilities for following tasks/questions. • What is an object diagram? What are object diagrams good for? • When is an object diagram called partial? What are partial ones good for? • When is an object diagram an object diagram (wrt. what)? • Is this an object diagram wrt. to that other thing? • How are system states and object diagrams related? • What does it mean that an OCL expression is satisfiable? • When is a set of OCL constraints said to be consistent? • Can you think of an object diagram which violates this OCL constraint? – 05 – 2013-11-06 – Sprelim – • Content: • Object Diagrams • Example: Object Diagrams for Documentation • OCL: consistency, satisfiability 2 /31

  2. Where Are We? – 05 – 2013-11-06 – main – 3 /31 You Are Here. N UML W E S = ( T , C , V, atr ) , SM S , SD CD , SM ϕ ∈ OCL CD , SD S ✔ D Model S , → SM ) S , → SD , F SD ) S , A expr ✔ ✔ M = (Σ B = ( Q SD , q 0 , A ✔ Instances ( cons 0 , Snd 0 ) π = ( σ 0 , ε 0 ) − − − − − − − − → ( σ 1 , ε 1 ) · · · w π = (( σ i , cons i , Snd i )) i ∈ N u 0 ! ! Mathematics – 05 – 2013-11-06 – Spostmap – G = ( N, E, f ) ! ! OD UML 4 /31

  3. Object Diagrams – 05 – 2013-11-06 – main – 5 /31 Graph Definition. A node labelled graph is a triple G = ( N, E, f ) consisting of • vertexes N , • edges E , • node labeling f : N → X , where X is some label domain, – 05 – 2013-11-06 – Sod – 6 /31

  4. D be a structure of signature S = ( T , C , V, atr ) D Object Diagrams S a system state. Definition. Let and σ ∈ Σ D ( C ) finite , Then any graph G = ( N, E, f ) where • nodes are identities (not necessarily alive), i.e. C }} × N, N ⊂ • edges correspond to “links” of objects, i.e. E ⊆ N × { v : τ ∈ V | τ ∈ { C 0 , 1 , C ∗ | C ∈ ∪ ( V � ( D ( T ) ∪ D ( C ∗ ))) ∀ ( u 1 , r, u 2 ) ∈ E : u 1 ∈ dom( σ ) ∧ u 2 ∈ σ ( u 1 )( r ) , • objects are labelled with attribute valuations and non-alive identities marked with “X”, i.e. X = { X } ˙ – 05 – 2013-11-06 – Sod – ∀ u ∈ N ∩ dom( σ ) : f ( u ) ⊆ σ ( u ) ∀ u ∈ N \ dom( σ ) : f ( u ) = { X } is called object diagram of σ . 7 /31 D ( C ) finite, ∪ ( V � ( D ( T ) ∪ D ( C ∗ ))) Graphical Representation of Object Diagrams S = ( { Int } , { C } , { v 1 : Int , v 2 : Int , r : C ∗ } , { C �→ { v 1 , v 2 , r }} ) . X = { X } ˙ N ⊂ E ⊂ N × V 0 , 1 , ∗ × N , u 1 ∈ dom( σ ) ∧ u 2 ∈ σ ( u 1 )( r ) , f ( u ) ⊆ σ ( u ) or f ( u ) = { X } • Assume • Consider σ = { u 1 �→ { v 1 �→ 1 , v 2 �→ 2 , r �→ { u 2 }} , u 2 �→ { v 1 �→ 3 , v 2 �→ 4 , r �→ ∅}} S and any D with D ( Int ) ⊇ { 1 , 2 , 3 , 4 } . • Then G = ( N, E, f ) = ( { u 1 , u 2 } , { ( u 1 , r, u 2 ) } , { u 1 �→ { v 1 �→ 1 , v 2 �→ 2 } , u 2 �→ { v 1 �→ 3 , v 2 �→ 4 }} , is an object diagram of σ wrt. – 05 – 2013-11-06 – Sod – 8 /31

  5. D ( C ) finite, ∪ ( V � ( D ( T ) ∪ D ( C ∗ ))) Graphical Representation of Object Diagrams S = ( { Int } , { C } , { v 1 : Int , v 2 : Int , r : C ∗ } , { C �→ { v 1 , v 2 , r }} ) . X = { X } ˙ N ⊂ E ⊂ N × V 0 , 1 , ∗ × N , u 1 ∈ dom( σ ) ∧ u 2 ∈ σ ( u 1 )( r ) , f ( u ) ⊆ σ ( u ) or f ( u ) = { X } • Assume • Consider σ = { u 1 �→ { v 1 �→ 1 , v 2 �→ 2 , r �→ { u 2 }} , u 2 �→ { v 1 �→ 3 , v 2 �→ 4 , r �→ ∅}} S and any D with D ( Int ) ⊇ { 1 , 2 , 3 , 4 } . • Then G = ( N, E, f ) = ( { u 1 , u 2 } , { ( u 1 , r, u 2 ) } , { u 1 �→ { v 1 �→ 1 , v 2 �→ 2 } , u 2 �→ { v 1 �→ 3 , v 2 �→ 4 }} , is an object diagram of σ wrt. • We may equivalently (!) represent G graphically as follows: u 1 : C u 2 : C – 05 – 2013-11-06 – Sod – r v 1 = 1 v 1 = 3 v 2 = 2 v 2 = 4 8 /31 UML Notation for Object Diagrams mandatory : id class optional � v 1 = d 1 “compartment” . . �� . optional v n = d n � r optional – 05 – 2013-11-06 – Sod – : id class 9 /31

  6. D ( C ) finite, ∪ ( V � ( D ( T ) ∪ D ( C ∗ ))) Object Diagrams: More Examples X = { X } ˙ N ⊂ E ⊂ N × V 0 , 1 , ∗ × N , u 1 ∈ dom( σ ) ∧ u 2 ∈ σ ( u 1 )( r ) , f ( u ) ⊆ σ ( u ) or f ( u ) = { X } σ = { 1 C �→ { p �→ ∅ , n �→ { 5 C }} , 5 C �→ { p �→ ∅ , n �→ ∅} , 1 D �→ { x �→ 23 }} vs. • ( ∅ , ∅ , ∅ ) 5 C : C 1 C : C n 1 D : D • n = ∅ p = ∅ x = 23 p = ∅ 1 C : C n 5 C : C 1 D : D • x = 23 – 05 – 2013-11-06 – Sod – • 1 C : C 5 C : C 1 D : D 1 C : C x 5 C : C 1 D : D • x = 23 10 /31 Complete vs. Partial Object Diagram D S . Definition. Let G = ( N, E, f ) be an object diagram of system state σ ∈ Σ We call G complete wrt. σ if and only if • G is object complete, i.e. • G consists of all alive objects, i.e. N = dom( σ ) , • G is attribute complete, i.e. T -typed attributes, • G comprises all “links” between alive objects, i.e. if u 2 ∈ σ ( u 1 )( r ) for some u 1 , u 2 ∈ dom( σ ) and r ∈ V , T ∪{ r �→ ( σ ( u )( r ) \ N ) | r ∈ V : σ ( u )( r ) \ N � = ∅} then ( u 1 , r, u 2 ) ∈ E , and T } . T := { v : τ ∈ V | τ ∈ • each node is labelled with the values of all i.e. for each u ∈ dom( σ ) , – 05 – 2013-11-06 – Sod – f ( u ) = σ ( u ) | V where V Otherwise we call G partial. 11 /31

  7. Complete vs. Partial Examples T ∪ { r �→ ( σ ( u )( r ) \ N ) | σ ( u )( r ) \ N } • N = dom( σ ) , if u 2 ∈ σ ( u 1 )( r ) , then ( u 1 , r, u 2 ) ∈ E , • f ( u ) = σ ( u ) | V Complete or partial? σ = { 1 C �→ { p �→ ∅ , n �→ { 5 C }} , 5 C �→ { p �→ ∅ , n �→ ∅} , 1 D �→ { x �→ 23 }} 5 C : C 1 C : C n 1 D : D • n = ∅ p = ∅ x = 23 p = ∅ 1 C : C n 5 C : C 1 D : D • – 05 – 2013-11-06 – Sod – x = 23 • 1 C : C 5 C : C 1 D : D 12 /31 Complete/Partial is Relative • Claim: • Each finite system state has exactly one complete object diagram. D • A finite system state can have many partial object diagrams. S | G is an object diagram of σ } • Each object diagram G represents a set of system states, namely G − 1 := { σ ∈ Σ • Observation : If somebody tells us , that a given (consistent) object diagram G is complete , we can uniquely reconstruct the corresponding system state. In other words: G − 1 is then a singleton. – 05 – 2013-11-06 – Sod – 13 /31

  8. T Corner Cases – 05 – 2013-11-06 – main – 14 /31 Closed Object Diagrams vs. Dangling References Find the 10 differences! (Both diagrams shall be complete.) 1 C : C n 5 C : C 1 C : C n 5 C : C p = { 1 C } p = { 7 C } Definition. Let σ be a system state. We say attribute v ∈ V 0 , 1 , ∗ has a dangling reference in object u ∈ dom( σ ) if and only if the attribute’s value comprises an object which is not alive in σ , i.e. if σ ( u )( v ) �⊂ dom( σ ) . We call σ closed if and only if no attribute has a dangling reference in – 05 – 2013-11-06 – Sodsconf – any object alive in σ . 15 /31

  9. Closed Object Diagrams vs. Dangling References Find the 10 differences! (Both diagrams shall be complete.) 1 C : C n 5 C : C 1 C : C n 5 C : C p = { 1 C } p = { 7 C } Definition. Let σ be a system state. We say attribute v ∈ V 0 , 1 , ∗ has a dangling reference in object u ∈ dom( σ ) if and only if the attribute’s value comprises an object which is not alive in σ , i.e. if σ ( u )( v ) �⊂ dom( σ ) . We call σ closed if and only if no attribute has a dangling reference in – 05 – 2013-11-06 – Sodsconf – T -typed attribute/value pairs only. any object alive in σ . Observation : Let G be the (!) complete object diagram of a closed system state σ . Then the nodes in G are labelled with 15 /31 S = ( { Int } , { C } , { n, p : C ∗ } , { C �→ { n, p }} ) . Special Notation • • Instead of 1 C : C n 5 C : C we want to write 1 C : C n 5 C : C p = ∅ p = ∅ or p p 1 C : C n 5 C : C | | – 05 – 2013-11-06 – Sodsconf – to explicitly indicate that attribute p : C ∗ has value ∅ (also for p : C 0 , 1 ). 16 /31

  10. Aftermath We slightly deviate from the standard (for reasons): • In the course, C 0 , 1 and C ∗ -typed attributes only have sets as values . UML also considers multisets, that is, they can have n u 1 : C u 2 : C n (This is not an object diagram in the sense of our definition because of the requirement on the edges E . Extension is straightforward but tedious.) • We allow to give the valuation of C 0 , 1 - or C ∗ -typed attributes in the values compartment . • Allows us to indicate that a certain r is not referring to another object. – 05 – 2013-11-06 – Sodsconf – • Allows us to represent “dangling references”, i.e. references to objects which are not alive in the current system state. • We introduce a graphical representation of ∅ values. 17 /31 The Other Way Round – 05 – 2013-11-06 – main – 18 /31

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend