lecture 6 class diagrams i
play

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

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


  1. Software Design, Modelling and Analysis in UML Lecture 6: Class Diagrams I 2015-11-12 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal – 6 – 2015-11-12 – main – Albert-Ludwigs-Universit¨ at Freiburg, Germany

  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 ) – 6 – 2015-11-12 – Sprelim – ✔ OD UML 2 /27

  3. Contents & Goals Last Lecture: • Object Diagrams • partial vs. complete; for analysis; for documentation. . . This Lecture: • Educational Objectives: Capabilities for following tasks/questions. • What is a class diagram? • For what purposes are class diagrams useful? • Could you please map this class diagram to a signature? • Could you please map this signature to a class diagram? • Content: • Study UML syntax. – 6 – 2015-11-12 – Sprelim – • Prepare (extend) definition of signature. • Map class diagram to (extended) signature. • Stereotypes. 3 /27

  4. UML Class Diagrams: Stocktaking – 6 – 2015-11-12 – main – 4 /27

  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 – 2015-10-22 – Ssemdom – – 6 – 2015-11-12 – Sstock – 7 /34 5 /27

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

  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 : 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 • has a set of operations . { A } y : Int B Each attribute has • a visibility , D • a name , a type , x : Int • a multiplicity , an order , – 6 – 2015-11-12 – Sstock – • an initial value , and • a set of properties , such as readOnly , ordered , etc. Wanted : places in the signature to represent the information from the picture. 7 /27

  8. Extended Signature – 6 – 2015-11-12 – main – 8 /27

  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 – 6 – 2015-11-12 – Sextsig – initial value expressions , e.g. OCL, or C++ in the Rhapsody tool, • a finite (possibly empty) set of properties P v . • 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 /27

  10. Conventions • We write � C, S C , a, t � if we want to refer to all aspects of C . • If the new aspects are irrelevant (for a given context), we simply write C i.e. old definitions are still valid. • We write � v : T, ξ, expr 0 , P v � if we want to refer to all aspects of v . • Write only v : T or v if details are irrelevant. • Note : All definitions we have up to now principally still apply as they are stated in terms of, e.g., C ∈ C — which still has a meaning with the extended view. – 6 – 2015-11-12 – Sextsig – For instance, system states and object diagrams will remain mostly unchanged. • The other way round : most of the newly added aspects do not contribute to the constitution of system states or object diagrams. 10 /27

  11. Mapping UML Class Diagrams to Extended Signatures – 6 – 2015-11-12 – main – 11 /27

  12. 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 ) � 0 , { P 1 , 1 , . . . , P 1 ,m 1 }� , . . . , � v ℓ : T ℓ , ξ ℓ , expr ℓ V ( n ) := {� v 1 : T 1 , ξ 1 , expr 1 0 , { P ℓ, 1 , . . . , P ℓ,m ℓ }�} atr ( n ) := { C �→ { v 1 , . . . , v ℓ }} – 6 – 2015-11-12 – Scdmap – where • “abstract” is determined by the font: • “active” is determined by the frame: � � , if n = or n = true C C { A } true , if n = C or n = C a ( n ) = t ( n ) = , otherwise false , otherwise false 12 /27

  13. Example � � Stereotype 1 , . . . , Stereotype n � � Package::C + r : C 0 , 1 = expr � � S 1 , . . . , S k � � s : D ∗ { ordered } C ξ 1 v 1 : T 1 = expr 1 0 { P 1 , 1 , . . . , P 1 ,m 1 } − v : Int = 27 . . w : Float { readOnly } . ξ ℓ v ℓ : T ℓ = expr ℓ 0 { P ℓ, 1 , . . . , P ℓ,m ℓ } � A { A } C ( n ) := � C, { S 1 , . . . , S k } , a ( n ) , t ( n ) � y : Int B 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 ℓ }�} D atr ( n ) := { C �→ { v 1 , . . . , v ℓ }} x : Int – 6 – 2015-11-12 – Scdmap – 13 /27

  14. What If Things Are Missing? It depends. • What does the standard say? (OMG, 2011a, 121) “ Presentation Options. The type, visibility, default, multiplicity, property string may be suppressed from being displayed, even if there are values in the model.” • Visibility : There is no “no visibility” — an attribute has a visibility in the (extended) signature. Some (and we) assume public as default, but conventions may vary. • Initial value : some assume it given by domain (such as “leftmost value”, but what is “leftmost” of Z ?). Some (and we) understand non-deterministic initialisation if not given. – 6 – 2015-11-12 – Scdmap – • Properties : probably safe to assume ∅ if not given at all. 14 /27

  15. Example Cont’d � � Stereotype 1 , . . . , Stereotype n � � Package::C + r : C 0 , 1 = expr � � S 1 , . . . , S k � � s : D ∗ { ordered } C ξ 1 v 1 : T 1 = expr 1 0 { P 1 , 1 , . . . , P 1 ,m 1 } − v : Int = 27 . . w : Float { readOnly } . ξ ℓ v ℓ : T ℓ = expr ℓ 0 { P ℓ, 1 , . . . , P ℓ,m ℓ } � A { A } C ( n ) := � C, { S 1 , . . . , S k } , a ( n ) , t ( n ) � y : Int B 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 ℓ }�} D atr ( n ) := { C �→ { v 1 , . . . , v ℓ }} x : Int – 6 – 2015-11-12 – Scdmap – 15 /27

  16. From Class Diagrams to Extended Signatures • We view a class diagram CD as a graph with nodes { n 1 , . . . , n N } (each “class rectangle” is a node). • C ( CD ) := { C ( n i ) | 1 ≤ i ≤ N } • V ( CD ) := � N i =1 V ( n i ) • atr ( CD ) := � N i =1 atr ( n i ) • In a UML model , we can have finitely many class diagrams, C D = {CD 1 , . . . , CD k } , which induce the following signature: – 6 – 2015-11-12 – Scdmap – � k k k � � � � S ( C D ) = C ( CD i ) , V ( CD i ) , atr ( CD i ) T , . i =1 i =1 i =1 (Assuming T given. In “reality” (i.e. in full UML), we can introduce types in class diagrams, the class diagram then contributes to T . Example: enumeration types.) 16 /27

  17. Is the Mapping a Function? Question : Is S ( C D ) well-defined ? – 6 – 2015-11-12 – Scdmap – 17 /27

  18. – 6 – 2015-11-12 – main – References 26 /27

  19. References Oestereich, B. (2006). Analyse und Design mit UML 2.1, 8. Auflage . Oldenbourg, 8. edition. OMG (2011a). Unified modeling language: Infrastructure, version 2.4.1. Technical Report formal/2011-08-05. OMG (2011b). Unified modeling language: Superstructure, version 2.4.1. Technical Report formal/2011-08-06. Schumann, M., Steinke, J., Deck, A., and Westphal, B. (2008). Traceviewer technical documentation, version 1.0. Technical report, Carl von Ossietzky Universit¨ at Oldenburg und OFFIS. – 6 – 2015-11-12 – main – 27 /27

Recommend


More recommend