lecture 15 uml state machines software quality assurance
play

Lecture 15: UML State Machines & Software Quality Assurance - PDF document

Softwaretechnik / Software-Engineering Lecture 15: UML State Machines & Software Quality Assurance 2018-07-02 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universitt Freiburg, Germany 15 2018-07-02 main


  1. Softwaretechnik / Software-Engineering Lecture 15: UML State Machines & Software Quality Assurance 2018-07-02 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universität Freiburg, Germany – 15 – 2018-07-02 – main – Topic Area Architecture & Design: Content • Introduction and Vocabulary VL 11 • Software Modelling . . • model; views / viewpoints; 4+1 view . • Modelling structure • (simplified) class & object diagrams VL 12 . . • (simplified) object constraint logic (OCL) . VL 13 • Principles of Design • modularity, separation of concerns • information hiding and data encapsulation . . • abstract data types, object orientation . • Design Patterns VL 14 • Modelling behaviour . • communicating finite automata (CFA) . . • Uppaal query language VL 15 • CFA vs. Software – 15 – 2018-07-02 – Sblockcontent – . • Model-driven/-based Software Engineering . . • Unified Modelling Language (UML) • basic and hierarchical state-machines 2 /67

  2. Content I (Architecture & Design) • CFA vs. Software • a CFA model is software • CFA at Work • drive to configuration, scenarios, invariants • tool demo (verifier). • Model-based/-driven Software Engineering • Unified Modelling Language • Brief History • Sub-Languages • UML Modes • UML State Machines • Hierarchical State Machines • Core State Machines • steps and run-to-completion steps – 15 – 2018-07-02 – Scontent – • Rhapsody 3 /67 CFA vs. Software – 15 – 2018-07-02 – main – 4 /67

  3. A CFA Model Is Software Definition. Software is a finite description S of a (possibly infinite) set � S � of (finite or infinite) computation paths of the form α 1 α 2 − → σ 1 − → σ 2 · · · σ 0 where • σ i ∈ Σ , i ∈ N 0 , is called state (or configuration ), and • α i ∈ A , i ∈ N 0 , is called action (or event ). The (possibly partial) function � · � : S �→ � S � is called interpreta- tion of S . • Let C ( A 1 , . . . , A n ) be a network of CFA. • Σ = Conf • A = Act λ 1 λ 2 λ 3 • � C � = { π = � � → � � → � � ℓ 0 , ν 0 � − − ℓ 1 , ν 1 � − − ℓ 2 , ν 2 � − − → · · · | π is a computation path of C} . – 15 – 2018-07-02 – Scfasw – • Note : the structural model just consists of the set of variables and the locations of C . 5 /67 Example: Software Specification Alphabet : • M – dispense cash only, ) e k n a r • C – return card only, F o g n I k r i D M • – dispense cash and return card. , 0 . 4 C a s - y b - C C ( g r o . a i d e m i k i • Customer : “I don’t care about the order of M and C ” w . s n o m m o c � � � � ω / / : � M p � � S 1 = M.C � C.M t t h C • Refined Specification : “be consistent: either always M.C or always C.M ” S 2 = ( M.C ) ω or ( C.M ) ω • Design Idea : “consider human errors: always do C.M ” S 1 = ( C.M ) ω – 15 – 2018-07-02 – Scfasw – • Implementation (goal): software S 2 behaves according to the design idea. 6 /67

  4. CFA and Queries at Work – 15 – 2018-07-02 – main – 8 /67

  5. Example: Vending Machine — Model Architecture water_selected WATER? water_enabled DWATER! idle soft_selected request_sent SOFT? DSOFT! soft_enabled C50, E1 CoinValidator User DTEA! TEA? DOK? tea_enabled A tea_selected E T T , F O OK! S R , T E A water_enabled := false, W OK soft_enabled := false, half_idle tea_enabled := false DOK ChoicePanel SYSTEM ENVIRONMENT DWATER DTEA DSOFT WaterDispenser SoftDispenser TeaDispenser Service FILLUP • Shared variables : • bool water_enabled, soft_enabled, tea_enabled; • int w = 3, s = 3, t = 3; – 15 – 2018-07-02 – Scfaatwork – • Note : Our model does not use scopes (“information hiding”) for channels. That is, ‘Service’ could send ‘WATER’ if the modeler wanted to. 9 /67 Design Sanity Check: Drive to Configuration • Question : Is is (at all) possible to have no water in the vending machine model? (Otherwise, the design is definitely broken.) • Approach : Check whether a configuration satisfying w = 0 is reachable, i.e. check N VM | = ∃ ♦ w = 0 . for the vending machine model N VM . – 15 – 2018-07-02 – Scfaatwork – 10 /67

  6. Design Check: Scenarios • Question : Is the following existential LSC satisfied by the model? (Otherwise, the design is definitely broken.) LSC: buy tea AC: true AM: initial I: permissive User Coin Validator Choice Panel C 50 C 50 ¬ E1 ! C 50 TEA • Approach : Use the following newly created CFA ‘Scenario’ C50! C50! C50! TEA! end_of_scenario instead of User and check whether location end_of_scenario is reachable, i.e. check N ′ VM | = ∃ ♦ Scenario . end_of_scenario . – 15 – 2018-07-02 – Scfaatwork – for the modified vending machine model N ′ VM . 11 /67 Design Verification: Invariants • Question : Is it the case that the “tea” button is only enabled if there is e 1.50 in the machine? (Otherwise, the design is broken.) • Approach : Check whether the implication ⇒ CoinValidator . have_c150 tea _ enabled = holds in all reachable configurations, i.e. check N VM | = ∀ � tea _ enabled CoinValidator . have_c150 imply for the vending machine model N VM . have_e1 E1? C50? soft_enabled := (s > 0) water_enabled := (w > 0), tea_enabled := (t > 0) idle have_c50 C50? C50? C50? water_enabled := (w>0) soft_enabled := (s > 0) tea_enabled := (t > 0) have_c100 have_c150 E1? – 15 – 2018-07-02 – Scfaatwork – tea_enabled := (t > 0) OK? OK? OK? OK? drink_ready 12 /67

  7. Design Verification: Sanity Check • Question : Is the “tea” button ever enabled? (Otherwise, the considered invariant tea _ enabled = ⇒ CoinValidator . have_c150 holds vacuously.) • Approach : Check whether a configuration satisfying water _ enabled = 1 is reachable. Exactly like we did with w = 0 earlier. – 15 – 2018-07-02 – Scfaatwork – 13 /67 Design Verification: Another Invariant • Question : Is it the case that, if there is money in the machine and water in stock, that the “water” button is enabled? • Approach : Check N VM | = ∀ � ( CoinValidator . have_c50 or CoinValidator . have_c100 or CoinValidator . have_c150 ) imply water _ enabled . have_e1 E1? C50? soft_enabled := (s > 0) water_enabled := (w > 0), tea_enabled := (t > 0) idle have_c50 C50? C50? C50? water_enabled := (w>0) soft_enabled := (s > 0) tea_enabled := (t > 0) have_c100 have_c150 E1? – 15 – 2018-07-02 – Scfaatwork – tea_enabled := (t > 0) OK? OK? OK? OK? drink_ready 14 /67

  8. Recall: Universal LSC Example LSC: buy water AC: true AM: invariant I: strict User CoinValidator ChoicePanel Dispenser C 50 ¬ ( C50 ! ∨ E1 ! ∨ pSOFT ! pWATER ∨ pTEA ! ∨ pFILLUP !) water _ in _ stock dWATER ¬ ( dSoft ! ∨ dTEA !) OK – 15 – 2018-07-02 – Scfaatwork – 15 /67 Content I (Architecture & Design) • CFA vs. Software • a CFA model is software • CFA at Work • drive to configuration, scenarios, invariants • tool demo (verifier). • Model-based/-driven Software Engineering • Unified Modelling Language • Brief History • Sub-Languages • UML Modes • UML State Machines • Hierarchical State Machines • Core State Machines • steps and run-to-completion steps – 15 – 2018-07-02 – Scontent – • Rhapsody 16 /67

  9. Model-based/-driven Software Engineering – 15 – 2018-07-02 – main – 17 /67 – 15 – 2018-07-02 – Smdse – 18 /67

  10. Model-Driven Software Engineering • (Jacobson et al., 1992): “System development is model building.” • Model based software engineering (MBSE): some (formal) models are used. • Model driven software engineering (MDSE): all artefacts are (formal) models. Idea elicit � requirements Structure Declarative �� model Behaviour � refine � requirements/ refine Declarative �� constraints Behaviour ′ � = ? � | Structure ′ Constructive �� design Behaviour � = ? refine refine | � Structure ′′ Constructive �� system model Behaviour ′ � generate/ program – 15 – 2018-07-02 – Smdse – Implementation 19 /67 – 15 – 2018-07-02 – Smdse – 20 /67

  11. Development Approaches task, problem outside-in user interface top-down bottom-up inside-out system software, hardware • top-down risk: needed functionality hard to realise on target platform. • bottom-up risk: lower-level units do not “fit together”. • inside-out risk: user interface needed by customer hard to realise with existing system, • outside-in risk: elegant system design not reflected nicely in (already fixed) UI. – 15 – 2018-07-02 – Smdse – 21 /67 Transform vs. Write-Down-and-Check – 15 – 2018-07-02 – Smdse – 22 /67

Recommend


More recommend