Chair of Software Engineering Software Architecture Bertrand Meyer ETH Zurich, February-May 2009 Lecture 1: Introduction.

Slides:



Advertisements
Similar presentations
Configuration management
Advertisements

Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 3: Abstract Data Types.
Lecture # 2 : Process Models
Karolina Muszyńska Based on:
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
Software Engineering and Design Principles Chapter 1.
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
Introduction To System Analysis and Design
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 5: Restaurant.
Chair of Software Engineering Object-Oriented Software Construction Bertrand Meyer Lesson 16 Last update: 25 May 2004 An O-O design example.
Design Creative Process of transferring the problem into a solution
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 2: Dealing with Objects I.
-5- Exception handling What is an exception? “An abnormal event” Not a very precise definition Informally: something that you don’t want to happen.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 2: Dealing with Objects I.
Chair of Software Engineering ATOT - Lecture 17, 28 May Advanced Topics in Object Technology Bertrand Meyer.
The Architecture Design Process
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 10: Project Presentation Ilinca.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
Chair of Software Engineering OOSC Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering OOSC - Lecture 4 1 Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 18: Undo/Redo.
Chapter 1 Principles of Programming and Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
What is Sure BDCs? BDC stands for Batch Data Communication and is also known as Batch Input. It is a technique for mass input of data into SAP by simulating.
Simple Program Design Third Edition A Step-by-Step Approach
EECE 310 Software Engineering Lecture 0: Course Orientation.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
INT-Evry (Masters IT– Soft Eng)IntegrationTesting.1 (OO) Integration Testing What: Integration testing is a phase of software testing in which.
Software Engineering Management Lecture 1 The Software Process.
CSC 395 – Software Engineering Lecture 13: Object-Oriented Analysis –or– Let the Pain Begin (At Least I’m Honest!)
CSE 219 Computer Science III Program Design Principles.
CS 140 Computer Programming (I) Second semester (3 credits) Imam Mohammad bin Saud Islamic University College of Computer Science and Information.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Software Testing Yonsei University 2 nd Semester, 2014 Woo-Cheol Kim.
1 Introduction to Software Engineering Lecture 1.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Object Oriented Software Development
The Software Development Process
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
1 Case Study Multi-Panel Interactive System. 2 The Problem Domain Build a general type of interactive system  Users interact with a set of panels  Web.
Fusion Design Overview Object Interaction Graph Visibility Graph Class Descriptions Inheritance Graphs Fusion: Design The overall goal of Design is to.
Chapter 2 Principles of Programming and Software Engineering.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
Principles of Programming. Achieving an Object-Oriented Design  Abstraction and Information Hiding  Object-Oriented Design  Functional Decomposition.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
CSCE 240 – Intro to Software Engineering Lecture 3.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Wrap up. Structures and views Quality attribute scenarios Achieving quality attributes via tactics Architectural pattern and styles.
Chair of Software Engineering Software Architecture Prof. Bertrand Meyer, Dr. Michela Pedroni ETH Zurich, February-May 2010 Lecture 1: Introduction.
Principles of Programming & Software Engineering
Principles of Programming and Software Engineering
EECE 310 Software Engineering
Applying Use Cases (Chapters 25,26)
Presentation transcript:

Chair of Software Engineering Software Architecture Bertrand Meyer ETH Zurich, February-May 2009 Lecture 1: Introduction

2 Software architecture The architecture of a software system is its structure and the documentation of that structure

3 Software architecture questions (examples) Software architecture answers questions such as:  What are the modules (components) of this system?  How are properties of a module known to developers?  What kinds of relation exist between the modules?  Should an inter-module link be replaced by a link of another kind (e.g. client  inheritance)?  How do modules A and B communicate?  How does the structure of system X differ from that of system Y?  How easy is it to adapt to adapt the structure to a change in requirements?

4 Software architecture is not… Algorithms, Data structures (Except if they affect some of the previous properties) Implementation techniques Software documentation (except on structural aspects) Hardware considerations (except if they affect some of the previous properties, e.g. because of concurrency)

5 Software architecture techniques Modularization Reuse techniques Abstraction techniques Information hiding Design patterns Architectural styles (pipes, filters, …)

6 Goal of the course Introduce you to the techniques of building large software systems of high quality, in particular:  Reliability  Extendibility  Reusability This includes in particular:  Principles of software quality  Object technology principles and methods; the practice of object-oriented analysis, design and implementation  Design patterns  Principles of building reusable software  Some key techniques of concurrent programming

7 Seven key topics  Modularity and reusability  Abstract Data Types  Design by Contract and other O-O principles  Design Patterns  Software architecture styles  Component-Based Development  Introduction to concurrency

8 Practical information

9 Course material Course page:  Check it at least twice a week Lecture material:  Lecture slides  Textbook (see next): Object-Oriented Software Construction, 2 nd edition -- Prentice Hall, 1997 Available from Polybuchhandlung (≈ CHF 63 with Legi) Exercise material:  Exercise sheets  Master solutions

10 Recommended books Bertrand Meyer “Object-Oriented Software Construction” Prentice Hall, 1997

11 Electronic forums Discussion forums: Inforum: Mailing list for each group Usual advice and rules:  Use the forums and mailing lists! Take advantage of every help you can get.  Don’t be shy. There are no stupid questions.  Criticism welcome, but always be polite to every participant and observe the etiquette.  To the whole teaching team (professor and assistants):

12 Exam: end of semester Tuesday, 26 May 2009, (normal class time) 2-hour exam No material allowed Covers all material in the semester

13 Teaching staff

14 Bertrand Meyer Office: RZ J6 Secretary: Claudia Günthart, (01)

Chair of Software Engineering Software Architecture Bertrand Meyer ETH Zurich, March-July 2009 A basic architecture example

16 Our first pattern example Multi-panel interactive systems Plan of the rest of this lecture:  Description of the problem: an example  An unstructured solution  A top-down, functional solution  An object-oriented solution yielding a useful design pattern  Analysis of the solution and its benefits

17 A reservation panel Flight sought from: To: Depart no earlier than: No later than: 18 Mar 2006 Choose next action: 0 – Exit 1 – Help 2 – Further enquiry 3 – Reserve a seat 18 Mar 2006 Santa Barbara Zurich ERROR: Choose a date in the future

18 A reservation panel Choose next action: 0 – Exit 1 – Help 2 – Further enquiry 3 – Reserve a seat AVAILABLE FLIGHTS: 2 Flt# LH 425Dep 8:25Arr 7:45Thru: Shanghai Flt# CP 082Dep 7:40Arr 9:15Thru: Hong Kong Flight sought from: To: Depart no earlier than: No later than: 18 Mar 2009 Santa Barbara Zurich

19 The transition diagram Help Initial Flight_query Seat_query Confirmation Reservation Help

20 A first attempt A program block for each state, for example: P Flight_query : display ‘‘enquiry on flights’’ screen repeat Read user’s answers and his exit choice C if Error_in_answer then output_message end until not Error_in_answer end process answer inspect C when 0 then goto P Exit when 1 then goto P Help... when n then goto P Reservation end

21 What’s wrong with the previous scheme?  Intricate branching structure (‘‘spaghetti bowl’’).  Extendibility problems: dialogue structure “wired” into program structure.

22 A functional, top-down solution Represent the structure of the diagram by a function transition (i, k) giving the state to go to from state i for choice k. This describes the transitions of any particular application. Function transition may be implemented as a data structure, for example a two-dimensional array.

23 The transition function 0 (Initial) 1 (Help) 2 (Confirmation) 3 (Reservation) 4 (Seats) 5 (Flights) 0123 Exit Return

24 The transition diagram Help Initial Flight_query Seat_query Confirmation Reservation Help

25 New system architecture execute_session initial transition execute_state is_final display read correct message process Level 3 Level 2 Level 1

26 New system architecture Procedure execute_session only defines graph traversal. It knows nothing about particular screens of a given application; it should be the same for all applications. execute_session -- Execute full session. local current_state, choice : INTEGER do current_state := initial repeat choice := execute_state (current_state) current_state := transition (current_state, choice) until is_final (current_state) end end

27 To describe an application  Provide transition function  Define initial state  Define is_final function

28 Actions in a state execute_state (current_state : INTEGER ): INTEGER -- Execute actions for current_state ; return user’s exit choice. local answer : ANSWER good : BOOLEAN choice : INTEGER do repeat display (current_state ) [answer, choice] := read (current_state ) good := correct (current_state, answer ) if not good then message (current_state, answer ) end until good end process (current_state, answer ) Result := choice end

29 Specification of the remaining routines  display (s ) outputs the screen associated with state s.  [a, e] := read (s ) reads into a the user’s answer to the display screen of state s, and into e the user’s exit choice.  correct (s, a ) returns true if and only if a is a correct answer for the question asked in state s.  If so, process (s, a ) processes answer a.  If not, message (s, a ) outputs the relevant error message.

30 Going object-oriented: The law of inversion How amenable is this solution to change and adaptation?  New transition?  New state?  New application? Routine signatures: execute_state (state : INTEGER ): INTEGER display (state : INTEGER ) read (state : INTEGER ): [ANSWER, INTEGER] correct (state : INTEGER ; a : ANSWER ): BOOLEAN message (state : INTEGER ; a : ANSWER ) process (state : INTEGER ; a : ANSWER ) is_final (state : INTEGER )

31 Data transmission All routines share the state as input argument. They must discriminate on it, e.g. : display (current_state : INTEGER ) do inspect current_state when state 1 then... when state 2 then... when state n then... end end Consequences:  Long and complicated routines.  Must know about one possibly complex application.  To change one transition, or add a state, need to change all.

32 The flow of control Underlying reason why structure is so inflexible: Too much DATA TRANSMISSION. current_state is passed from execute_session (level 3) to all routines on level 2 and on to level 1 Worse: there’s another implicit argument to all routines – application. Can’t define execute_session, display, execute_state,... as library components, since each must know about all interactive applications that may use it.

33 The visible architecture execute_session initial transition execute_state is_final display read correct message process Level 3 Level 2 Level 1

34 The real story execute_session initial transition execute_state is_final display read correct message process Level 3 Level 2 Level 1 state

35 The law of inversion  If your routines exchange too much data, put your routines into your data. In this example: the state is everywhere!

36 Going O-O Use STATE as the basic abstract data type (and class). Among features of every state:  The routines of level 1 (deferred in class STATE )  execute_state, as above but without the argument current_state

37 Rearranging the modules by data abstractions STATE execute_session Level 3 Level 2 Level 1 initial transition execute_state display read correct message process is_final

38 Class STATE deferred class STATE feature choice : INTEGER-- User’s selection for next step input : ANSWER-- User’s answer for this step display -- Show screen for this step. deferred end read -- Get user’s answer and exit choice, -- recording them into input and choice. deferred ensure input /= Void end

39 Class STATE correct : BOOLEAN -- Is input acceptable? deferred end message -- Display message for erroneous input. require not correct deferred end process -- Process correct input. require correct deferred end

40 Class STATE execute_state local good : BOOLEAN do from until good loop display read good := correct if not good then message end end process choice := input. choice end end

41 Class structure STATE * FLIGHT_QUERY RESERVATION … execute_state + display + read + correct + message + process + display + read + correct + message + process + display + read + correct + message + process + display * read * correct * message * process *

42 To describe a state of an application Write a descendant of STATE : class FLIGHT_QUERY inherit STATE feature display do... end read do... end correct : BOOLEAN do... end message do... end process do... end end

43 APPLICATION Rearranging the modules by data abstractions STATE execute_session Level 3 Level 2 Level 1 initial transition execute_state display read correct message process is_final

44 Describing a complete application No ‘‘main program’’ but class representing a system. Describe application by remaining features at levels 1 and 2:  Function transition.  State initial.  Boolean function is_final.  Procedure execute_session.

45 Implementation decisions  Represent transition by an array transition : n rows (number of states), m columns (number of choices), given at creation  States numbered from 1 to n; array states yields the state associated with each index (Reverse not needed: why?)  No deferred boolean function is_final, but convention: a transition to state 0 denotes termination.  No such convention for initial state (too constraining). Attribute initial_number.

46 Describing an application class APPLICATION create make feature initial : INTEGER make (n, m : INTEGER ) -- Allocate with n states and m possible choices. do create transition. make (1, n, 1, m ) create states.make (1, n ) end feature {NONE } -- Representation of transition diagram transition : ARRAY2 [STATE ] -- State transitions states : ARRAY [STATE ] -- State for each index

47 The array of states STATES (ENQUIRY_ ON_FLIGHTS) (ENQUIRY_ ON_SEATS) (INITIAL) (CONFIRMATION) (RESERVATION) A polymorphic data structure

48 Executing a session execute_session -- Run one session of application local current_state : STATE-- Polymorphic! index : INTEGER do from index := initial until index = 0 loop current_state := states [index ] current_state. execute_state index :=transition [index, current_state. choice ] end end Dynamic binding

49 Class structure STATE * FLIGHT_QUERY RESERVATION … execute_state + display + read + correct + message + process + display + read + correct + message + process + display + read + correct + message + process + display * read * correct * message * process *

50 Other features of APPLICATION put_state ( s : STATE; number : INTEGER ) -- Enter state s with index number require 1 <= number number <= states. upper do states. put (number, s ) end choose_initial (number : INTEGER ) -- Define state number number as the initial state. require 1 <= number number <= states. upper do first_number := number end

51 More features of APPLICATION put_transition (source, target, label : INTEGER ) -- Add transition labeled label from state -- number source to state number target. require 1 <= source ; source <= states. upper 0 <= target ;target <= states. upper 1 <= label ; label <= transition. upper2 do transition. put (source, label, target ) end invariant 0 <= st_number st_number <= n transition. upper1 = states. upper end source target label

52 To build an application Necessary states — instances of STATE — should be available. Initialize application: create a. make (state_count, choice_count ) Assign a number to every relevant state s : a. put_state (s, n ) Choose initial state n0 : a. choose_initial (n0 ) Enter transitions: a. put_transition (sou, tar, lab ) May now run: a. execute_session

53 Open architecture During system evolution you may at any time:  Add a new transition ( put_transition ).  Add a new state ( put_state ).  Delete a state (not shown, but easy to add).  Change the actions performed in a given state ...

54 Note on the architecture Procedure execute_session is not ‘‘the function of the system” but just one routine of APPLICATION. Other uses of an application:  Build and modify: add or delete state, transition, etc.  Simulate, e.g. in batch (replaying a previous session’s script), or on a line-oriented terminal.  Collect statistics, a log, a script of an execution.  Store into a file or data base, and retrieve. Each such extension only requires incremental addition of routines. Doesn’t affect structure of APPLICATION and clients.

55 The system is open Key to openness: architecture based on types of the problem’s objects (state, transition graph, application). Basing it on “the” apparent purpose of the system would have closed it for evolution. Real systems have no top

56 Object-Oriented Design It’s all about finding the right data abstractions