lecture 12 proto ocl
play

Lecture 12: Proto-OCL, (iii) Modelling structure VL 11 . a) - PowerPoint PPT Presentation

Topic Area Architecture & Design: Content Content Proto-OCL Introduction and Vocabulary VL 10 syntax, semantics, Software Modelling I Softwaretechnik / Software-Engineering Proto-OCL vs. OCL. . . (i) views and


  1. Topic Area Architecture & Design: Content Content • Proto-OCL • Introduction and Vocabulary VL 10 • syntax, semantics, • Software Modelling I Softwaretechnik / Software-Engineering • Proto-OCL vs. OCL. . . (i) views and viewpoints, the 4+1 view . • Proto-OCL vs. Software (ii) model-driven/-based software engineering • An outlook on UML Lecture 12: Proto-OCL, (iii) Modelling structure VL 11 . a) (simplified) class diagrams . • Principles of (Good) Design . b) (simplified) object diagrams Modularisation & Design Patterns VL 12 c) (simplified) object constraint logic (OCL) • modularity, separation of concerns d) Unified Modelling Language (UML) • information hiding and data encapsulation • abstract data types, object orientation • Principles of Design 2017-07-03 • ...by example . (i) modularity, separation of concerns . . (ii) information hiding and data encapsulation • Architecture Patterns (iii) abstract data types, object orientation (iv) Design Patterns • Layered Architectures, Pipe-Filter, Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Model-View-Controller. VL 13 • Software Modelling II – 12 – 2017-07-03 – Sblockcontent – • Design Patterns . – 12 – 2017-07-03 – Scontent – Albert-Ludwigs-Universität Freiburg, Germany (i) Modelling behaviour . – 12 – 2017-07-03 – main – . a) communicating finite automata • Strategy, Examples b) Uppaal query language VL 14 c) basic state-machines • Libraries and Frameworks . . . d) an outlook on hierarchical state-machines 2 /66 3 /66 Content Partial vs. Complete Object Diagrams Special Case: Anonymous Objects • Proto-OCL • syntax, semantics, If the object diagram • By now we discussed “ object diagram represents system state ”: • Proto-OCL vs. OCL. • Proto-OCL vs. Software { 1 C 7 � { p 7 � � , n 7 � { 5 C }} , : C 5 C : C p n p 1 C : C n 1 D : D 1 C : C : D 5 C 7 � { p 7 � � , n 7 � � } , � p = � p = � p = � x = 23 p = � x = 23 1 D 7 � { p 7 � { 5 C } , x 7 � 23 }} n = � n = � • An outlook on UML What about the other way round...? is considered as complete , then it denotes the set of all system states • Principles of (Good) Design • Object diagrams can be partial , e.g. { 1 C 7 � { p 7 � � , n 7 � { c }}} , c 7 � { p 7 � � , n 7 � � } , d 7 � { p 7 � { c } , x 7 � 23 }} • modularity, separation of concerns 1 C : C n 5 C : C 1 D : D • information hiding and data encapsulation or 1 C : C 5 C : C 1 D : D where c � D ( C ) , d � D ( D ) , c 6 = 1 C . x = 23 • abstract data types, object orientation � we may omit information. Intuition : different boxes represent different objects. • ...by example • Is the following object diagram partial or complete ? • Architecture Patterns 5 C : C p • Layered Architectures, Pipe-Filter, 1 C : C n 1 D : D p = � p = � x = 23 n = � Model-View-Controller. • If an object diagram – 12 – 2017-07-03 – Scontent – • Design Patterns – 11 – 2017-06-26 – Sod – – 11 – 2017-06-26 – Sod – – 12 – 2017-07-03 – main – • has values for all attributes of all objects in the diagram, and – 12 – 2017-07-03 – main – • Strategy, Examples • if we say that it is meant to be complete then we can uniquely reconstruct a system state � . 39 /51 40 /51 • Libraries and Frameworks 4 /66 5 /66 6 /66

  2. Motivation Constraints on System States C C x : Int c 0,1 • Example : for all C -instances, x should never have the value 27 . a D A 0,1 ∀ c ∈ allInstances C • x ( c ) � = 27 Towards Object Constraint Logic (OCL) • Proto-OCL Syntax wrt. signature ( T , C , V, atr , F, mth ) , c is a logical variable , C ∈ C : — “Proto-OCL” — • How do I precisely, formally tell my developers that F ::= : τ C c All D -instances having a link to the same C object | allInstances C : 2 τ C should have links to the same A . | v ( F ) : τ C → τ ⊥ , if v : τ ∈ atr ( C ) • That is, the following system state is forbidden in the software: | v ( F ) : τ C → τ D , if v : D 0 , 1 ∈ atr ( C ) | : τ C → 2 τ D , if v : D ∗ ∈ atr ( C ) v ( F ) : A a : D c : C c : D a : A | f ( F 1 , . . . , F n ) : τ 1 × · · · × τ n → τ, if f : τ 1 × · · · × τ n → τ : τ C × 2 τ C × B ⊥ → B ⊥ | ∀ c ∈ F 1 • F 2 Note: formally, it is a proper system state . – 12 – 2017-07-03 – main – – 12 – 2017-07-03 – Socl – – 12 – 2017-07-03 – Socl – • Use (Proto-)OCL : “Dear developers, please only use system states which satisfy:” • The formula above in prefix normal form : ∀ c ∈ allInstances C • � = ( x ( c ) , 27) ∀ d 1 ∈ allInstances C • ∀ d 2 ∈ allInstances C • c ( d 1 ) = c ( d 2 ) = ⇒ a ( d 1 ) = a ( d 2 ) 7 /66 8 /66 9 /66 Semantics Semantics Cont’d Example: Evaluate Formula for System State • Proto-OCL Types: C • Proto-OCL is a three-valued logic: a formula evaluates to true , false , or ⊥ . 1 C : C σ : x : Int • I � τ C � = D ( C ) ˙ I � τ ⊥ � = D ( τ ) ˙ I � 2 τ C � = D ( C ∗ ) ˙ ∪ {⊥} , ∪ {⊥} , ∪ {⊥} x = 13 • Example : ∧ I ( · , · ) : { true , false , ⊥} × { true , false , ⊥} → { true , false , ⊥} is defined as follows: • I � B ⊥ � = { true , false } ˙ ∪ {⊥} , I � Z ⊥ � = Z ˙ ∪ {⊥} ∀ c ∈ allInstances C • x ( c ) � = 27 • Functions: x 1 true true true false false false ⊥ ⊥ ⊥ x 2 true false ⊥ true false ⊥ true false ⊥ • We assume f I given for each function symbol f ( → in a minute). • Recall prefix notation : ∀ c ∈ allInstances C • � =( x ( c ) , 27) ∧ I ( x 1 , x 2 ) true false ⊥ false false false ⊥ false ⊥ Note : � = is a binary function symbol, 27 is a 0 -ary function symbol. • Proto-OCL Semantics (interpretation function): We assume common logical connectives ¬ , ∧ , ∨ , . . . with canonical 3-valued interpretation. • Example : • I � c � ( σ, β ) = β ( c ) (assuming β is a type-consistent valuation of the logical variables), • Example : + I ( · , · ) : ( Z ˙ ∪ {⊥} ) × ( Z ˙ ∪ {⊥} ) → Z ˙ ∪ {⊥} I � ∀ c ∈ allInstances C • � =( x ( c ) , 27) � ( σ, ∅ ) = true , because... • I � allInstances C � ( σ, β ) = dom( σ ) ∩ D ( C ) , � x 1 + x 2 , if x 1 � = ⊥ and x 2 � = ⊥ I � � =( x ( c ) , 27) � ( σ, β ) , β := ∅ [ c := 1 C ] = { c �→ 1 C } � σ ( I � F � ( σ, β )) ( v ) , if I � F � ( σ, β ) ∈ dom( σ ) + I ( x 1 , x 2 ) = ⊥ , otherwise • I � v ( F ) � ( σ, β ) = (if not v : C 0 , 1 ) ⊥ , otherwise = � = I ( I � x ( c ) � ( σ, β ) , I � 27 � ( σ, β ) ) We assume common arithmetic operations − , /, ∗ , . . . � σ ( u ′ )( v ) , if I � F � ( σ, β ) = { u ′ } ⊆ dom( σ ) and relation symbols >, <, ≤ , . . . with monotone 3-valued interpretation. = � = I ( σ ( I � c � ( σ, β ) )( x ) , 27 I ) • I � v ( F ) � ( σ, β ) = (if v : C 0 , 1 ) ⊥ , otherwise • And we assume the special unary function symbol isUndefined : = � = I ( σ ( β ( c ) )( x ) , 27 I ) • I � f ( F 1 , . . . , F n ) � ( σ, β ) = f I ( I � F 1 � ( σ, β ) , . . . , I � F n � ( σ, β )) , – 12 – 2017-07-03 – Socl – – 12 – 2017-07-03 – Socl – – 12 – 2017-07-03 – Socl – = � = I ( σ ( 1 C )( x ) , 27 I ) � true , if x = ⊥ ,  true , if I � F 2 � ( σ, β [ c := u ]) = true for all u ∈ I � F 1 � ( σ, β ) isUndefined I ( x ) =  false , otherwise  = � = I ( 13 , 27 ) = true ...and 1 C is the only C -object in σ : I � allInstances C � ( σ, ∅ ) = { 1 C } . • I � ∀ c ∈ F 1 • F 2 � ( σ, β ) = false , if I � F 2 � ( σ, β [ c := u ]) = false for some u ∈ I � F 1 � ( σ, β )  ⊥ , otherwise isUndefined I is definite : it never yields ⊥ .  10 /66 11 /66 12 /66

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