lecture 12 structural software modelling
play

Lecture 12: Structural Software Modelling 2015-06-25 Prof. Dr. - PowerPoint PPT Presentation

Softwaretechnik / Software-Engineering Lecture 12: Structural Software Modelling 2015-06-25 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal 12 2015-06-25 main Albert-Ludwigs-Universit at Freiburg, Germany Contents of the Block


  1. Softwaretechnik / Software-Engineering Lecture 12: Structural Software Modelling 2015-06-25 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal – 12 – 2015-06-25 – main – Albert-Ludwigs-Universit¨ at Freiburg, Germany

  2. Contents of the Block “Design” (i) Introduction and Vocabulary L 1: 20.4., Mo Introduction T 1: 23.4., Do (ii) Principles of Design L 2: 27.4., Mo Development L 3: 30.4., Do a) modularity Process, Metrics L 4: 4.5., Mo b) separation of concerns T 2: 7.5., Do c) information hiding and data encapsulation L 5: 11.5., Mo d) abstract data types, object orientation - 14.5., Do L 6: 18.5., Mo Requirements (iii) Software Modelling L 7: 21.5., Do Engineering - 25.5., Mo a) views and viewpoints, the 4+1 view - 28.5., Do T 3: 1.6., Mo b) model-driven/based software engineering - 4.6., Do c) Unified Modelling Language (UML) L 8: 8.6., Mo d) modelling structure L 9: 11.6., Do L 10: 15.6., Mo 1. (simplified) class diagrams T 4: 18.6., Do 2. (simplified) object diagrams L 11: 22.6., Mo 3. (simplified) object constraint logic (OCL) Architecture & L 12: 25.6., Do – 12 – 2015-06-25 – Scontents – Design, Software L 13: 29.6., Mo e) modelling behaviour L 14: 2.7., Do Modelling 1. communicating finite automata T 5: 6.7., Mo 2. Uppaal query language L 15: 9.7., Do Quality Assurance 3. basic state-machines L 16: 13.7., Mo L 17: 16.7., Do 4. an outlook on hierarchical state-machines Invited Talks T 6: 20.7., Mo (iv) Design Patterns L 18: 23.7., Do Wrap-Up 2 /38

  3. Contents & Goals Last Lecture: • Design basics and vocabulary: modularity, separation of concerns, information hiding, data encapsulation, ADT, . . . This Lecture: • Educational Objectives: Capabilities for following tasks/questions. • What is the signature defined by this class diagram? • Give a system state corresponding to this class diagram. • Which system state is denoted by this object diagram? • To which value does this Proto-OCL formula evaluate on the given system state? • Give system states such that the given formula evaluates to true/false/ ⊥ . • Why is Proto-OCL a 3-valued logic? – 12 – 2015-06-25 – Sprelim – • Content: • Class Diagrams • Object Diagrams • Proto-OCL 4 /38

  4. – 12 – 2015-06-25 – main – Class Diagrams 5 /38

  5. Object System Signature Definition. An (Object System) Signature is a 6-tuple S = ( T , C , V, atr , F, mth ) where • T is a set of (basic) types , • C is a finite set of classes , • V is a finite set of typed attributes , i.e., each v ∈ V has type • V is a finite set of typed attributes v : T , i.e., each v ∈ V has type T , • atr : C → 2 V maps each class to its set of attributes. • F is a finite set of typed behavioural features f : T 1 , . . . , T n → T , • mth : C → 2 F maps each class to its set of behavioural features. – 12 – 2015-06-25 – Sumlsig – • A type can be a basic type τ ∈ T , or C 0 , 1 , or C ∗ , where C ∈ C . Note : Inspired by OCL 2.0 standard OMG (2006), Annex A. 6 /38

  6. Object System Signature Example S 0 = ( { Int } , { C, D } , { x : Int , p : C 0 , 1 , n : C ∗ } , { C �→ { p, n } , D �→ { p, x }} , { f : Int → Bool , get x : Int } , { C �→ ∅ , D �→ { f, get x }} ) – 12 – 2015-06-25 – Sumlsig – 7 /38

  7. Object System Signature Example S 0 = ( { Int } , { C, D } , { x : Int , p : C 0 , 1 , n : C ∗ } , { C �→ { p, n } , D �→ { p, x }} , { f : Int → Bool , get x : Int } , { C �→ ∅ , D �→ { f, get x }} ) D n • 0 .. 1 x : Int • 0 .. ∗ × C p f ( Int ) : Bool × • × get x () : Int p 0 .. 1 – 12 – 2015-06-25 – Sumlsig – 7 /38

  8. And The Other Way Round D n • x : Int 0 .. 1 • 0 .. ∗ × C p f ( Int ) : Bool × • × get x () : Int p 0 .. 1 – 12 – 2015-06-25 – Sumlsig – 8 /38

  9. Shorthand Notation D n • x : Int 0 .. 1 • 0 .. ∗ × C p f ( Int ) : Bool × • × get x () : Int p 0 .. 1 D n x : Int 0 .. 1 0 .. ∗ C p f ( Int ) : Bool p get x () : Int 0 .. 1 In particular: • visibility for attributes and association ends ( + , − , # , ∼ ): later • initial values, properties : not here , cf. UML lecture – 12 – 2015-06-25 – Sumlsig – • associations in general (names, reading direction, ternary; visibility, navigability, etc. of association ends): not here , cf. UML lecture • inheritance : later (maybe) • behavioural features : not here , cf. UML lecture 9 /38

  10. Object System Structure Definition. A Object System Structure of signature S = ( T , C , V, atr , F, mth ) is a domain function D which assigns to each type a domain, i.e. • τ ∈ T is mapped to D ( T ) , • C ∈ C is mapped to an infinite set D ( C ) of (object) identities . • object identities of different classes are disjoint, i.e. ∀ C, D ∈ C : C � = D → D ( C ) ∩ D ( D ) = ∅ , • on object identities, (only) comparision for equality “ = ” is defined. • C ∗ and C 0 , 1 for C ∈ C are mapped to 2 D ( C ) . – 12 – 2015-06-25 – Sumlstruc – We use D ( C ) to denote � C ∈ C D ( C ) ; analogously D ( C ∗ ) . Note : We identify objects and object identities, because both uniquely determine each other (cf. OCL 2.0 standard). 10 /38

  11. Basic Object System Structure Example Wanted : a structure for signature S 0 = ( { Int } , { C, D } , { x : Int , p : C 0 , 1 , n : C ∗ } , { C �→ { p, n } , D �→ { p, x }} , { f : Int → Bool , get x : Int } , { C �→ ∅ , D �→ { f, get x }} ) A structure D maps • τ ∈ T to some D ( τ ) , C ∈ C to some identities D ( C ) (infinite, pairwise disjoint), • C ∗ and C 0 , 1 for C ∈ C to D ( C 0 , 1 ) = D ( C ∗ ) = 2 D ( C ) . D ( Int ) = Z – 12 – 2015-06-25 – Sumlstruc – N + × { C } ∼ D ( C ) = = { 1 C , 2 C , 3 C , ... } N + × { D } ∼ D ( D ) = = { 1 D , 2 D , 3 D , ... } 2 D ( C ) D ( C 0 , 1 ) = D ( C ∗ ) = 2 D ( D ) D ( D 0 , 1 ) = D ( D ∗ ) = 11 /38

  12. System State Definition. Let D be a structure of S = ( T , C , V, atr , F, mth ) . 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 – 12 – 2015-06-25 – Sumlstruc – 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 . 12 /38

  13. System State Example S 0 = ( { Int } , { C, D } , { x : Int , p : C 0 , 1 , n : C ∗ } , { C �→ { p, n } , D �→ { p, x }} , { f : Int → Bool , get x : Int } , { C �→ ∅ , D �→ { f, get x }} ) D ( Int ) = Z , D ( C ) = { 1 C , 2 C , 3 C , ... } , D ( D ) = { 1 D , 2 D , 3 D , ... } A system state is a partial function σ : D ( C ) � ( V � ( D ( T ) ∪ D ( C ∗ ))) such that • dom( σ ( u )) = atr ( C ) , • σ ( u )( v ) ∈ D ( τ ) if v : τ, τ ∈ T , • σ ( u )( v ) ∈ D ( C ∗ ) if v : D ∗ or v : D 0 , 1 with D ∈ C . – 12 – 2015-06-25 – Sumlstruc – 13 /38

  14. System State Example S 0 = ( { Int } , { C, D } , { x : Int , p : C 0 , 1 , n : C ∗ } , { C �→ { p, n } , D �→ { p, x }} , { f : Int → Bool , get x : Int } , { C �→ ∅ , D �→ { f, get x }} ) D ( Int ) = Z , D ( C ) = { 1 C , 2 C , 3 C , ... } , D ( D ) = { 1 D , 2 D , 3 D , ... } A system state is a partial function σ : D ( C ) � ( V � ( D ( T ) ∪ D ( C ∗ ))) such that • dom( σ ( u )) = atr ( C ) , • σ ( u )( v ) ∈ D ( τ ) if v : τ, τ ∈ T , • σ ( u )( v ) ∈ D ( C ∗ ) if v : D ∗ or v : D 0 , 1 with D ∈ C . • Concrete , explicit system state: σ 1 = { 1 C �→ { p �→ ∅ , n �→ { 5 C }} , 5 C �→ { p �→ ∅ , n �→ ∅} , 1 D �→ { p �→ { 5 C } , x �→ 23 }} .. – 12 – 2015-06-25 – Sumlstruc – • Alternative : symbolic system state σ 2 = { c 1 �→ { p �→ ∅ , n �→ { c 2 }} , c 2 �→ { p �→ ∅ , n �→ ∅} , d �→ { p �→ { c 2 } , x �→ 23 }} . assuming c 1 , c 2 ∈ D ( C ) , d ∈ D ( D ) , c 1 � = c 2 . Can be seen as denoting a set of system states including σ 1 — how many? 13 /38

  15. Class Diagrams at Work – 12 – 2015-06-25 – main – 14 /38

  16. Visualisation of Implementation • The class diagram syntax can be used to visualise code : provide rules which map (parts of) the code to class diagram elements. pac ; 1 package pac ; 1 package – 12 – 2015-06-25 – Scdatwork – 2 2 import pac .D; 3 import pac .C; 3 4 4 p u bli c c l a s s C { 5 p u bli c c l a s s D { 5 6 6 p u bli c D n ; 7 p r i va te i nt x ; 7 8 8 p r i n t n x () { p u bli c void 9 p u bli c i nt get x () 9 System . out . p r i n t f ( 10 { return x ; } ; 10 ”%i \ n” , n . get x () } ; ) ; 11 11 12 p u bli c D() {} ; 12 p u bli c C() {} ; 13 } 13 } 14 15 /38

Recommend


More recommend