lecture 6 class diagrams i
play

Lecture 6: Class Diagrams I 2016-11-15 Prof. Dr. Andreas Podelski, - PowerPoint PPT Presentation

Software Design, Modelling and Analysis in UML Lecture 6: Class Diagrams I 2016-11-15 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universitt Freiburg, Germany 6 2016-11-15 main Course Map N UML W E CD ,


  1. Software Design, Modelling and Analysis in UML Lecture 6: Class Diagrams I 2016-11-15 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universität Freiburg, Germany – 6 – 2016-11-15 – main –

  2. Course Map N UML W E CD , SM ϕ ∈ OCL CD , SD S ! ✔ Model S = ( T , C , V, atr ) , SM expr S , SD ✔ ✔ M = (Σ D S , A S , → SM ) B = ( Q SD , q 0 , A S , → SD , F SD ) ✔ ( cons 0 , Snd 0 ) π = ( σ 0 , ε 0 ) − − − − − − − − → ( σ 1 , ε 1 ) · · · w π = (( σ i , cons i , Snd i )) i ∈ N Instances u 0 ✔ Mathematics G = ( N, E, f ) ✔ UML OD – 6 – 2016-11-15 – main – 2 /31

  3. Content • Stocktaking • Extended Signatures • Structures for Extended Signatures • Semantically Relevant • Mapping Class Diagrams to Extended Signatures • What if things are missing ? • (Temporary) Abbreviations • Stereotypes – 6 – 2016-11-15 – Scontent – 3 /31

  4. UML Class Diagrams: Stocktaking – 6 – 2016-11-15 – main – 4 /31

  5. Recall: Signature vs. Class Diagram Basic Object System Signature Another Example S = ( T , C , V, atr ) where • (basic) types T and classes C (both finite), • typed attributes V , � from T , or C 0 , 1 or C � , for some C � C , • atr : C � 2 V mapping classes to attributes. Example : – 2 – 2016-10-20 – Ssemdom – – 6 – 2016-11-15 – Sstock – 7 /20 5 /31

  6. That’d Be Too Simple � � Stereotype 1 , . . . , Stereotype n � � Package::C + r : Package::C 0 , 1 = expr s : D ∗ { ordered } − v : Int = 27 w : Float { readOnly } A { A } y : Int B D x : Int – 6 – 2016-11-15 – Sstock – 6 /31

  7. What Do We Want / Have to Cover? A class � � Stereotype 1 , . . . , Stereotype n � � • has a set of stereotypes , Package::C • has a name , + r : Package::C 0 , 1 = expr s : D ∗ { ordered } • belongs to a package , − v : Int = 27 • can be abstract , w : Float { readOnly } • can be active , • has a set of attributes , A { A } • has a set of operations . y : Int B Each attribute has D • a visibility , x : Int • a name , a type , • a multiplicity , an order , • an initial value , and • a set of properties , such as readOnly , ordered , etc. – 6 – 2016-11-15 – Sstock – Wanted : places in the signature to represent the information from the picture. 7 /31

  8. Extended Signature – 6 – 2016-11-15 – main – 8 /31

  9. Extended Signature Definition. An (Extended) Object System Signature is a quadruple S = ( T , C , V, atr ) where • T is a set of (basic) types, • C is a finite set of classes � C, S C , a, t � where • S C is a finite (possibly empty) set of stereotypes , • a ∈ B is a boolean flag indicating whether C is abstract , • t ∈ B is a boolean flag indicating whether C is active , • V is a finite set of attributes � v : T, ξ, expr 0 , P v � where • T is a type from T , or C 0 , 1 , C ∗ for some C ∈ C , • ξ ∈ { public , private , protected , package } is the visibility , � �� � � �� � � �� � � �� � :=+ := − := ∼ :=# • an initial value expression expr 0 given as a word from a language for initial value expressions , e.g. OCL, or C++ in the Rhapsody tool; write ‘ ⊲ ⊳ ’ to explicitly not give an initial value expression. • a finite (possibly empty) set of properties P v . – 6 – 2016-11-15 – Sextsig – • atr : C → 2 V maps each class to its set of attributes. We use S C to denote the set � C ∈ C S C of stereotypes in S . 9 /31

  10. Extended Signature Example � C, S C , a, t � ∈ C , � v : T, ξ, expr 0 , P v � ∈ V S = ( T , C , V, atr ) , � { Int , Float } , S = {� Package::C , { Stereotype 1 , . . . , Stereotype n } , 0 , 0 � , � A , ∅ , 1 , 0 � , � B , ∅ , 1 , 0 � , � D , ∅ , 0 , 1 �} , {� r : Package::C 0 , 1 , + , expr , ∅� , � s : D ∗ , + , ⊲ ⊳, { ordered }� , � v : Int , − , 27 , ∅� , � w : Float , + , ⊲ ⊳, { readOnly }� , � x : Int , + , ⊲ ⊳, ∅� , � y : Int , + , ⊲ ⊳, ∅�} , � { Package::C �→ { r, s, v, w } , A �→ { y } , B �→ ∅ , D �→ { x }} – 6 – 2016-11-15 – Sextsig – 10 /31

  11. Conventions • We write � C, S C , a, t � if we want to refer to all aspects of class C . • If the new aspects are irrelevant (for a given context), we simply write C i.e. old definitions (written in terms of C ) are still valid. • Similarly, we write � v : T, ξ, expr 0 , P v � if we want to refer to all aspects of attribute v . • Write only v : T or v if details are irrelevant . – 6 – 2016-11-15 – Sextsig – 11 /31

  12. Structures of Extended Signatures Recall : Definition. A Basic Object System Structure of a Basic Object System Signature S = ( T , C , V, atr ) is a domain function D which assigns to each type a domain, i.e. • τ ∈ T is mapped to D ( τ ) , • C ∈ C is mapped to an infinite set D ( C ) of (object) identities. Note: Object identities only have the “ = " operation. • Sets of object identities for different classes are disjoint, i.e. ∀ C, D ∈ C : C � = D → D ( C ) ∩ D ( D ) = ∅ . • C ∗ and C 0 , 1 for C ∈ C are mapped to 2 D ( C ) . We use D ( C ) to denote � C ∈ C D ( C ) ; analogously D ( C ∗ ) . – 6 – 2016-11-15 – Sextsig – 12 /31

  13. Structures of Extended Signatures New : Definition. An (Object System) Structure of an (Extended Object System) Sig- nature S = ( T , C , V, atr ) is a domain function D which assigns to each type a domain, i.e. • τ ∈ T is mapped to D ( τ ) , • C ∈ C is mapped to an infinite set D ( C ) of (object) identities. Note: Object identities only have the “ = " operation. • Sets of object identities for different classes are disjoint, i.e. ∀ C, D ∈ C : C � = D → D ( C ) ∩ D ( D ) = ∅ . • C ∗ and C 0 , 1 for C ∈ C are mapped to 2 D ( C ) . We use D ( C ) to denote � C ∈ C D ( C ) ; analogously D ( C ∗ ) . – 6 – 2016-11-15 – Sextsig – 12 /31

  14. System States of Extended Signatures Recall : Definition. Let D be a basic structure of basic signature S = ( T , C , V, atr ) . A system state of S wrt. D is a type-consistent mapping σ : D ( C ) � ( V � ( D ( T ) ∪ D ( C ∗ ))) . That is, for each u ∈ D ( C ) , C ∈ C , if u ∈ dom( σ ) • dom( σ ( u )) = atr ( C ) • σ ( u )( v ) ∈ D ( τ ) if v : τ, τ ∈ T • σ ( u )( v ) ∈ D ( D ∗ ) if v : D 0 , 1 or v : D ∗ with D ∈ C We call u ∈ D ( C ) alive in σ if and only if u ∈ dom( σ ) . We use Σ D S to denote the set of all system states of S wrt. D . – 6 – 2016-11-15 – Sextsig – 13 /31

  15. System States of Extended Signatures New : Definition. Let D be a structure of extended signature S = ( T , C , V, atr ) . A system state of S wrt. D is a type-consistent mapping σ : D ( C ) � ( V � ( D ( T ) ∪ D ( C ∗ ))) . That is, for each u ∈ D ( C ) , C ∈ C , if u ∈ dom( σ ) • dom( σ ( u )) = atr ( C ) • σ ( u )( v ) ∈ D ( τ ) if v : τ, τ ∈ T • σ ( u )( v ) ∈ D ( D ∗ ) if v : D 0 , 1 or v : D ∗ with D ∈ C • ∀ � C, S C , 1 , t � ∈ C • dom( σ ) ∩ D ( C ) = ∅ . We call u ∈ D ( C ) alive in σ if and only if u ∈ dom( σ ) . – 6 – 2016-11-15 – Sextsig – We use Σ D S to denote the set of all system states of S wrt. D . 13 /31

  16. Semantical Relevance • The semantics (or meaning) of an extended object system signature S wrt. a structure D is the set of system states Σ D S . • The semantics (or meaning) of an extended object system signature S is the set of sets of system states wrt. some structure of S , i.e. the set { Σ D S | D is structure of S } . Which of the following aspects is semantically relevant , i.e. does contribute to the constitution of system states? A class Each attribute has • has a set of stereotypes , • a visibility , • has a name , • a name , a type , • belongs to a package , • a multiplicity , an order , • can be abstract , • an initial value , and • can be active , • a set of properties , – 6 – 2016-11-15 – Sextsig – such as readOnly , ordered , etc. • has a set of attributes , • has a set of operations (later). 14 /31

  17. Mapping UML Class Diagrams to Extended Signatures – 6 – 2016-11-15 – main – 15 /31

  18. From Class Boxes to Extended Signatures A class box n induces an (extended) signature class as follows: n : � � S 1 , . . . , S k � � C ξ 1 v 1 : T 1 = expr 1 0 { P 1 , 1 , . . . , P 1 ,m 1 } . . . ξ ℓ v ℓ : T ℓ = expr ℓ 0 { P ℓ, 1 , . . . , P ℓ,m ℓ } � C ( n ) := � C, { S 1 , . . . , S k } , a ( n ) , t ( n ) � V ( n ) := {� v 1 : T 1 , ξ 1 , expr 1 0 , { P 1 , 1 , . . . , P 1 ,m 1 }� , . . . , � v ℓ : T ℓ , ξ ℓ , expr ℓ 0 , { P ℓ, 1 , . . . , P ℓ,m ℓ }�} atr ( n ) := { C �→ { v 1 , . . . , v ℓ }} where • “abstract” is determined by the font: • “active” is determined by the frame: � � true , if n = C or n = C { A } true , if n = C or n = C – 6 – 2016-11-15 – Scdmap – a ( n ) = t ( n ) = false , otherwise false , otherwise 16 /31

Recommend


More recommend