21 functional and modular design
play

21) Functional and Modular Design Prof. Dr. U. Amann 1. Functional - PowerPoint PPT Presentation

Fakultt Informatik, Institut fr Software- und Multimediatechnik, Lehrstuhl fr Softwaretechnologie 21) Functional and Modular Design Prof. Dr. U. Amann 1. Functional Design Technische Universitt Dresden 2. Modular Design


  1. Fakultät Informatik, Institut für Software- und Multimediatechnik, Lehrstuhl für Softwaretechnologie 21) Functional and Modular Design Ø Prof. Dr. U. Aßmann 1. Functional Design Ø Technische Universität Dresden 2. Modular Design (Change- Ø Institut für Software- und Multimediatechnik Oriented Design) Ø 3. Use-Case Based Design http://st.inf.tu-dresden.de Ø Version 13-0.1 20.12.2010

  2. Obligatory Readings Ø Ghezzi Chapter 3, Chapter 4, esp. 4.2 Ø Pfleeger Chapter 5, esp. 5.7 Ø David Garlan and Mary Shaw. An Introduction to Software Architecture. In: Advances in Software Engineering and Knowledge Engineering, Volume I, edited by V.Ambriola and G.Tortora, World Scientific Publishing Company, New Jersey, 1993. Ø Also appears as CMU Software Engineering Institute Technical Report CMU/SEI-94-TR-21, ESC-TR-94-21. Ø http://www-2.cs.cmu.edu/afs/cs/project/able/ftp/intro_softarch/ intro_softarch.pdf Modular Design Prof. U. Aßmann 2

  3. Literature Ø [Parnas] David Parnas. On the Criteria To Be Used in Decomposing Systems into Modules. Communications of the ACM Dec. 1972 (15) 12. Ø [Shaw/Garlan] Software Architecture. 1996. Prentice-Hall. Modular Design Prof. U. Aßmann 3

  4. 21.1 FUNCTIONAL DESIGN Modular Design Prof. U. Aßmann 4

  5. Function-Oriented Methods Ø Examples: Ø Stepwise function refinement resulting in function trees Ø Modular decomposition with information hiding (Change-oriented modularization, Parnas) Ø Meyers Design-by-contract: Contracts are specified for functions with pre- and postconditions Ø (see OCL lecture) Ø Dijkstra’s and Bauer’s axiomatic refinement (not discussed here) Which functionality will the system have? What are the subfunctions of a function? Modular Design Prof. U. Aßmann 5

  6. A Start for a Function Tree Ø How to design the control software for a tea automaton? Produce Tea produce tea Modular Design Prof. U. Aßmann 6

  7. First Refinement of a Function Tree produce tea Produce Tea composition .. is composed of .. Put tea in pot Add boiling water add put tea Wait boiling wait in pot water Modular Design Prof. U. Aßmann 7

  8. Second Refinement of a Function Tree produce tea Produce Tea Put tea in pot Fetch tea from tea box add Open pot put tea boiling wait in pot Close pot water Add boiling water Wait fetch open close tea from pot pot tea box Modular Design Prof. U. Aßmann 8

  9. Third Refinement of a Function Tree produce Produce Tea tea Put tea in pot Fetch tea from tea box Open pot Close pot add put tea Add boiling water boiling wait in pot Boil water water Open pot Pour water in Close pot pour Wait fetch open close boil open close water tea from pot pot water pot pot tea box in pot Modular Design Prof. U. Aßmann 9

  10. Function Trees Ø Function trees can also be derived by a 1:1 mapping from a functional requirements tree (see ZOPP requirements lecture) Ø Usually, for a system several function trees are develop, starting with top-level functions in the context model Ø Stepwise Refinement works usually top-down (Hierarchic decomposition) Ø Bottom-up strategy (composition) possible Ø Middle-out strategy blends composition and decomposition Ø Development of the “subfunction-of” (“call”) relationship: a part-of relationship for functions: the function has which parts (subfunctions)? Ø Usually implemented by call relationship (call graph) Ø Syntactic stepwise refinement is indifferent about the semantics of the refined model Ø Semantic stepwise refinement proves that the semantics of the program or model is unchanced Ø Systems developed by semantic refinement are correct by construction Ø Functions are actions , if they work on visible state Ø In functional design, state is disregarded Ø State is important in action-oriented design, actions are usually related to state transitions! Modular Design Prof. U. Aßmann 10

  11. Function Polyhierarchies Ø If subfunctions are shared, polyhierarchies result with several roots and shared subtrees produce produce tea coffee add put put tea boiling coffee wait in pot water in pot fetch fetch pour open close boil open close Coffee tea from water pot pot water pot pot from tea box in pot tea box Modular Design Prof. U. Aßmann 11

  12. Other Trees with Other Part-Of Relationships Ø Many concepts can be stepwise refined and decomposed. Hierarchic decomposition is one of the most important development methods in Software Enineering: Ø Problem trees Ø Goal trees Ø Acceptance test trees Ø Requirements trees • Function trees • Feature trees (function trees describing grouping, variability and extensibility) Ø Attack trees Ø Fault trees Ø …. Ø The development is always by divide and conquer. Ø Think about: Which part-of relationships do they develop? Modular Design Prof. U. Aßmann 12

  13. 21.1.2 MODULAR COMPOSITION: GROUPING MODULES AND COHESION Modular Design Prof. U. Aßmann 13

  14. Grouping Functions to Modules to Support Cohesion Ø Group functions according to cohesion: “which function belongs to which other function?” Ø Minimize coupling of modules Ø Maximize coherence: encapsulate dependencies within a module Module Tea Box { Module Tea Automaton { Fetch tea from tea box Produce Tea } Add boiling water Wait } Module Pot { Open pot Put tea in pot Module Water Boiler { Pour water in pot Boil water Close pot } } Modular Design Prof. U. Aßmann 14

  15. Grouping Functions to Modules or Classes in UML Ø Functions can often be grouped to objects (object-oriented encapsulation) Ø Then, they can be actions working on the state of the object (begin of object-orientation) TeaBox <<module>> TeaAutomaton fetchTea() produceTea() addBoilingWater() wait() Pot open() <<module>> putIn(Tea) WaterBoiler pourIn(Water) boilWater() close() Modular Design Prof. U. Aßmann 15

  16. Heuristics and Best Practices Ø Don't group too many items onto one abstraction level or into one module ( slim interface principle) Ø Technical modules or classes (classes that do not stem from domain modeling) can be found in similar ways, by grouping cohesive functions together Ø Identify material modules or classes with CRUD interfaces (see TeaBox and Pot): Ø Create Ø Read Ø Update Ø Delete Ø Identify tool modules or classes with “active functions”: • List<Material> • Edit<Material> • Navigate<Material> Ø Identify command modules or classes (Design Pattern Command) • Tools are specific commands, working on materials Modular Design Prof. U. Aßmann 16

  17. Result: Call-Based Architectural Style Ø Functional design leads to call-based architectural style with statically known callees (static call graph) System call return Module call Module call return call return return Module cal l return Modular Design Prof. U. Aßmann 17

  18. Grouping Other Trees with other Part-Of Relationships Ø Any hierarchic relationship can be grouped to modules based on cohesion Ø Problem trees è problem modules Ø Goal trees è goal modules Ø Acceptance test trees è acceptance test modules Ø Feature trees (describing variability, extensibility) è Feature modules Ø Attack trees è attack modules Ø Fault trees è fault modules Ø …. Modular Design Prof. U. Aßmann 18

  19. Why is Function-Oriented Design Important? Ø Implementation of function trees in a functional language Ø ... or a modular imperative language, e.g., Modula, C, or Ada-83. Ø In some application areas, object-oriented design and languages have severe disadvantages Ø Employment in safety-critical systems: Ø Proofs about the behavior of a system are only possible if the architecture and the call graph are static. Then they can be used for proofs Ø Due to polymorphism, object-oriented systems have dynamic architectures (don't program your AKW with Java!) Ø In embedded and real-time systems: Ø Object-oriented language implementations usually are slower than those of modular languages Ø ... and eat up more memory Ø In high-speed systems: Ø Operating systems, database systems, compilers, ... Modular Design Prof. U. Aßmann 19

  20. (Rep. from ST-1, left out here) 21.2 CHANGE-ORIENTED MODULARIZATION WITH INFORMATION HIDING (VARIABILITY) Modular Design Prof. U. Aßmann 20

  21. What is a Module? Ø Software should, according to the divide-and-conquer principle, also physically be divided into basic parts, modules Ø A module groups a set of functions or actions Ø A module can be developed independently Ø errors can be traced down to modules Ø modules can be tested before assembling Ø A module can be exchanged independently Ø A module can be reused Ø The terms module and component mean pretty much the same Ø Often, a module is a programming-language supported component Ø Here: a module is a simple component Ø In the past, different component models have been developed Ø A component model defines features of components, their compositionality, and how large systems are built with them (architecture) Ø In course “Component-based SE”, we will learn about many different component models Modular Design Prof. U. Aßmann 21

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