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.

Slides:



Advertisements
Similar presentations
1 Design by Contract Building Reliable Software. 2 Software Correctness Correctness is a relative notion  A program is correct with respect to its specification.
Advertisements

Chair of Software Engineering Object-Oriented Software Construction Bertrand Meyer Lesson 16 Last update: 25 May 2004 An O-O design example.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 17: Topological Sort Algorithm.
Chair of Software Engineering ATOT - Lecture 17, 28 May Advanced Topics in Object Technology Bertrand Meyer.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
Chair of Software Engineering Software Architecture Bertrand Meyer ETH Zurich, February-May 2009 Lecture 1: Introduction.
Chapter 10 Class and Method Design
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
C++ fundamentals.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
Domain-Specific Software Engineering Alex Adamec.
Ranga Rodrigo. Class is central to object oriented programming.
Object Oriented Software Development
Design Patterns.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour.
CISC6795: Spring Object-Oriented Programming: Polymorphism.
An Introduction to Software Architecture
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Interaction Modeling. Introduction (1) Third leg of the modeling tripod. It describes interaction within a system. The class model describes the objects.
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
Unified Modeling Language, Version 2.0
Detailed design – class design Domain Modeling SE-2030 Dr. Rob Hasker 1 Based on slides written by Dr. Mark L. Hornick Used with permission.
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 10 Use Case Design.
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.
1 Introduction to Software Engineering Lecture 1.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
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.
Architectural Patterns Support Lecture. Software Architecture l Architecture is OVERLOADED System architecture Application architecture l Architecture.
Software Engineering Principles. SE Principles Principles are statements describing desirable properties of the product and process.
Slide 1 Systems Analysis and Design With UML 2.0 An Object-Oriented Approach, Second Edition Chapter 2: Introduction to Object-Oriented Systems Analysis.
Object Oriented Software Development
 Week08.  Review Schedule Weeks 8-14  This week o Review last class o Introduce Class Diagrams o ICE-03 Sheridan SYST Engineering Quality Systems.
Object-Oriented Programming Chapter Chapter
OMT Modeling 1. Object Model : presented by the object model and the data dictionary. 2. Dynamic Model: presented by the state diagrams and event flow.
Object Oriented Programming
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Slide 1 Systems Analysis and Design With UML 2.0 An Object-Oriented Approach, Second Edition Chapter 2: Introduction to Object-Oriented Systems Analysis.
1 Unified Modeling Language, Version 2.0 Chapter 2.
Integration Testing Beyond unit testing. 2 Testing in the V-Model Requirements Detailed Design Module implementation Unit test Integration test System.
31/01/ Selection If selection construct.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Next Back MAP MAP F-1 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
What is this? SE-2030 Dr. Mark L. Hornick 1. Same images with different levels of detail SE-2030 Dr. Mark L. Hornick 2.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
Basic Characteristics of Object-Oriented Systems
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.
Topic 4: Distributed Objects Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Slide 1 Unified Modeling Language, Version 2.0 Object-Oriented SAD.
Chair of Software Engineering Software Architecture Prof. Bertrand Meyer, Dr. Michela Pedroni ETH Zurich, February-May 2010 Lecture 1: Introduction.
Paul Ammann & Jeff Offutt
Systems Analysis and Design With UML 2
Unified Modeling Language
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
About the Presentations
Computer Programming.
UML Class Diagrams: Basic Concepts
Paul Ammann & Jeff Offutt
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Applying Use Cases (Chapters 25,26)
Presentation transcript:

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 applications are an example Each session goes through a number of states  Finite state machine  Automatic Teller Machine  A state corresponds to a fill-in-the-blanks panel  User is adding to a database of information  Depending upon user choices transitions occur to other states

3 Example Panel – Enquiry on Flights – Flight fromSomewhereFlight toAnywhere Departure on or after not soon enough on or before Preferred airline(s): Special requirements: Available flights: 1 Flt# AA 42 Dep 8:25 Arr 7:45 Thru: Chicago Choose next_action 0 Exit 1 Help 2 Further enquiry 3 Reserve seat too late

4 A State Transition Diagram Help 1 Initial 5 Confirmation 4 Reservation 2 Enquiry_ on_flights 3 Enquiry_ on_seats Numbers are choices in panel

5 The Problem Create a design and implementation for such applications General & flexible solution Things to think about  Finite state machine may be very large  Applications can have hundreds of states and thousands of transitions  Structure of the system is subject to change  Cannot foresee all possible states & transitions  No specific application is mentioned  What if you need many variations

6 The Problem – 2 A general design – a set of reusable modules – would be a huge benefit Getting the problem to work is only a part of the solution and insufficient for the task Customer's requirements go far beyond  mere correctness  mere functionality

7 First Attempt Block/Module oriented – procedural System made of a number of blocks  One for each state in the FSM

8 First Attempt – 2 Enquiry_Block "Display Enquiry on Flight panel" repeat get user's answer and choice C for next step if error in answer then output error fi until not error in answer "Process answer" case C in C0 : goto Exit_Block C1 : goto Help_Block C2 : goto Reservation_Block... esac Similarly for all other states Easy to devise, does the job Terrible for meeting requirements Similarly for all other states Easy to devise, does the job Terrible for meeting requirements

9 What are the Problems Block Design? Use goto's (Dijkstra)  Usually symptomatic of deeper problem Branch structure (goto's) are an exact implementation of the graph  Vulnerable to change  Add a new state –add new block, change all other blocks  Add a new transition –Change all blocks that should use it

10 What are the Problems – 2 Forget reusability across applications  Specific to one application Want not just a solution but a quality solution  Have to work harder What does quality mean for this system?

11 Top Down – Functional Solution Problems seem to be due to the traversal (goto) structure Generalizing the transition diagram will gain generality Model the function transition as a transition table representation of a FSM  Designate one state as initial  One or more states as final

12 Transition Table Initial 2 Flights 3 Seats 4 Reserv. 5 Confirm Choice StateState 0 Help -1 Final back

13 Top Down Decomposition execute_sessioninitialtransitionexecute_stateis_finaldisplay readcorrectmessageprocess

14 Implement execute_session execute_session is -- Execute a complete session local state, next : INTEGER do state := initial -- start in initial state repeat -- next is var parameter execute_state (state, next ) state := transition ( state, next ) until is_final ( state ) end end

15 Implement execute_state execute_state ( in s : INTEGER, out c : INTEGER ) is -- c contains the user's choice for next state local a : ANSWER ; ok :BOOLEAN do repeat display (s ) -- display panel for state s read ( s, a ) -- get user answer in a ok := correct ( s, a ) until ok end process ( s, a ) c := next_choice ( a ) -- get user choice for panel end State s is argument for all functions! What will be the structure/design of display?

16 What are the Problems Top Down? Tight coupling  State is argument to every routine Means long and complicated control structure  Case statements everywhere on state Violates single choice principle  Too many locations need to know about all states  difficult to modify as states added or removed Not reusable/general – except as a template  implicit argument in all functions is the application  Generality  know about all states in all applications

17 An OO Solution Instead of building components around operations while distributing data  OO does reverse  build around data and distribute operations Use most important data types as basis for modules  Routines are attached to data to which it relates most closely In our example state should be a class Routines exchange too much data ?  put routines in your data

18 State as Class What would be handed over to state?  All operations that characterize a state  Displaying screen  Analyzing answer  Checking answer  Producing error messages  Processing correct answer  Customize for each state

19 Class State Deferred class Deferred features Execute is effective because we know its behaviour * STATE input : ANSWER choice : INTEGER execute correct : BOOLEAN display * read * message * process * execute is local ok : BOOLEAN do from ok := false until ok loop display ; read ; ok := correct if not ok then message end end ensure ok end

20 Inheritance & Implementation STATE describes the general notion of state  execute is the same for all states  other routines must be customized Use deferred classes to specify general situation and provide for extension Use inheritance to specify particular states  Implement deferred routines * STATE INITIAL RESERVATION CONFIRMATION

21 Architecture of System Separates elements common to all states and elements specific to individual states Common elements do not need to be redeclared in descendants Satisfies open-closed principle  STATE is closed  Inheritance opens it State is typical of behaviour classes  deferred classes capture common behaviour Inheritance & Deferral are key for reusable components

22 Completing the System Design How do we represent transitions and an actual application? Have to take care of managing a session  What execute_session did in top down What is missing?  The notion of the specific application

23 Application Class Features  execute  how to execute the application  initial & is_final  special states – properties of application  transition  mapping from state to state May want to add more features  Add new state or transition  Store in a data base ...

24 Application Class – 2 class application feature initial : INTEGER execute is local st : STATE ; st_number : INTEGER do from st_number : initial until st_number = 0 loop st := associated_state.item ( st_number ) st.execute st_number := transition.item (st.number, st.choice ) end put_state ( st : STATE; sn : INTEGER) choose_initial (sn : INTEGER ) put_transition (source, target, label : INTEGER ) feature { NONE } transition : ARRAY2 [ STATE, CHOICE ] associated_state : ARRAY [ STATE ] end notes in next slide

25 Implementing the Design Number states from 1..N for the application  Array associated_state of APPLICATION gives the STATE associated with a number  It is polymorphic Represent transition as an P (states) x Q(choices) array transition Attribute initial represents the initial state Creation procedure of APPLICATION uses creation procedures of ARRAY and ARRAY2 –see p691 & 692 of textbook Building an application is relatively easy due to separation of parts

26 Points to Think About Forget about a main program Focus on data abstraction  Leads to structures that can more easily change and are more easily reused Don't ask  What does the system do?  It is not a function Big win from OO  clear, general, manageable, change-ready abstractions

27 Points to Think About – 2 Don't worry too much about modelling the real world  Goto version is a close model but poor design Heuristic to find the classes  Look for data transmissions and concepts that appear in communication between numerous components of a system What counts in OO design is how good are your abstractions for structuring your software. Above all else, worry about finding the right abstractions

28 How Not to Use Inheritance Class CAR, class PERSON put together to define a new class CAR_OWNER Every CAR_OWNER is both a PERSON and a CAR ? CAR PERSON CAR_OWNER

29 How Not to Use Inheritance – 2 Correct relationship is client–supplier Do not make a class B inherit from class A unless you can somehow make the argument that one can view every instance of B also as an instance of A CAR PERSON CAR_OWNER

30 Use versus Inheritance – 1 When the is view is legitimate, the has view can be taken instead  The reverse is not usually true  CAR_OWNER Two criteria help us resolve such arguments  Though they sometimes fail to give a clear cut solution

31 Rule of Change Client relations typically permits change, while inheritance does not  If B inherits from A then every B object is an A object and no object can change this property  If a B object has a component of type A it is very possible to change that component (up to the constraints supplied by the type system)

32 Use versus Inheritance – 2 Basic rule  Client is a has relationship  Inheritance is an is_a relationship It is a wicked problem to decide  due to difficulties of system modelling Compare the following  Every software engineer is an engineer  In every software engineer there is an engineer  Every software engineer can have an engineer component

33 Rule of Change – Example  class SWENG inherit ENGINEER... class SWENG2 feature me : ENGINEER... class SWENG3 feature me : VOCATION... In the first, object relationship cannot be changed dynamically In the other two, new values can be assigned to me – up to type constraints  Software engineer is also a juggler Do not use inheritance for a perceived is_a relation if the corresponding object components may have to be changed at run time.

34 Polymorphism Rule Inheritance is appropriate for is_a relations if data structure components of a more general type may need to be attached to objects of more specific type