SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture # 05: Design Principles I - Correctness and Robustness SWE 316: Software.

Slides:



Advertisements
Similar presentations
CSE Lecture 10 – Functions
Advertisements

1 Software Testing and Quality Assurance Lecture 13 - Planning for Testing (Chapter 3, A Practical Guide to Testing Object- Oriented Software)
Ch 3: Unified Process CSCI 4320: Software Engineering.
 Both System.out and System.err are streams—a sequence of bytes.  System.out (the standard output stream) displays output  System.err (the standard.
Programming Logic and Design Fourth Edition, Introductory
Error Management with Design Contracts Karlstad University Computer Science Error Management with Design Contracts Eivind J. Nordby, Martin Blom, Anna.
Introduction To System Analysis and Design
© Copyright 2011 John Wiley & Sons, Inc.
Component-Level Design
Fall 2007CS 225 Introduction to Software Design Chapter 1.
Software Testing and Quality Assurance
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
Chapter 1 Principles of Programming and Software Engineering.
Chapter 7 design rules.
Chapter 1 Program Design
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
The chapter will address the following questions:
Dr. Ken Hoganson, © August 2014 Programming in R STAT8030 Programming in R COURSE NOTES 1: Hoganson Programming Languages.
® IBM Software Group © 2006 IBM Corporation Writing Good Use Cases Module 4: Detailing a Use Case.
Chapter 4 Design Principles I Correctness and Robustness
1COM6030 Systems Analysis and Design © University of Sheffield 2005 COM 6030 Software Analysis and Design Lecture 4 - System modelling Dr Richard Clayton.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
Prologue: The Software Process. Main Phases of Software Process 1. Requirements Analysis (answers “WHAT?”) Specifying what the application must do 2.
C++ Code Analysis: an Open Architecture for the Verification of Coding Rules Paolo Tonella ITC-irst, Centro per la Ricerca Scientifica e Tecnologica
Chapter 5 Design Principles II: Flexibility, Reusability, and Efficiency.
Lecture # 06 Design Principles II
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 11 : Frameworks SWE 316: Software Design and Architecture  To understand.
Chapter 5 Design Principles II: Flexibility, Reusability, and Efficiency.
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
Comp2110 Software Design lecture 13Detailed Design (1)  detailed design contrasted with high level design  introducing the Observer Design Pattern 
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 7 Requirements and Domain Classes SWE 316: Software Design and Architecture.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Chapters 4&5 Design Principles: Correctness, Robustness, Flexibility, Reusability, and Efficiency.
Software Design Deriving a solution which satisfies software requirements.
1 Software Design Overview Reference: Software Engineering, by Ian Sommerville, Ch. 12 & 13.
Low-Level Detailed Design SAD (Soft Arch Design) Mid-level Detailed Design Low-Level Detailed Design Design Finalization Design Document.
1 Systems Analysis and Design in a Changing World, Thursday, January 18, 2007.
1 Introduction to Software Engineering Lecture 1.
SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
Today’s Agenda  Reminder: HW #1 Due next class  Quick Review  Input Space Partitioning Software Testing and Maintenance 1.
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
Modelling Class T07 Conceptual Modelling – Behaviour References: –Conceptual Modeling of Information Systems (Chapters 11, 12, 13 and 14)
Chapter 4 Design Principles I Correctness and Robustness.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 13 Creational Design Pattern SWE 316: Software Design and Architecture.
DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes.
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.
Designing Classes CS239 – Jan 26, Key points from yesterday’s lab  Enumerated types are abstract data types that define a set of values.  They.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Object Oriented Programming
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Architecture View Models A model is a complete, simplified description of a system from a particular perspective or viewpoint. There is no single view.
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
ANU comp2110 Software Design lecture 8 COMP2110 Software Design in 2004 lecture 8 Software Architecture 1 of 2 (design, lecture 3 of 6) Goal of this small.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Chapter 7 Creational Design Pattern. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFrameworkDetailed.
A FIRST BOOK OF C++ CHAPTER 14 THE STRING CLASS AND EXCEPTION HANDLING.
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.
Chapter 10 Software quality. This chapter discusses n Some important properties we want our system to have, specifically correctness and maintainability.
Coupling and Cohesion Schach, S, R. Object-Oriented and Classical Software Engineering. McGraw-Hill, 2002.
CSCI 51 Introduction to Programming Dr. Joshua Stough February 26, 2009.
Principles of Programming & Software Engineering
Chapter ? Quality Assessment
Principles of Programming and Software Engineering
Component-Level Design
Component-Level Design
Component-Level Design
Software Design Lecture : 9.
Presentation transcript:

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture # 05: Design Principles I - Correctness and Robustness SWE 316: Software Design and Architecture  Introducing two design Principles:  Correctness  Robustness Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission. Ch 4 Requirements Analysis Design Implementation ArchitectureFrameworkDetailed Design Key:= less affected

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Correctness Goal: That each artifact satisfies designated requirements, and that together they satisfy all of the application’s requirements. 4.1 Correctness InterfacesModularizationRobustnessDesign Details 2/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Approaches to correctness  How can we know that a design is correct or even sufficient?  Approaches to correctness  Informal approaches  Formal approaches  Informal approaches: to be convinced that the design covers the required functionality.  Formal approaches  Formal methods for establishing correctness involve applying mathematical logic to analyzing the way in which the variables change  Formal methods are usually applied when the design enters the detailed design Correctness InterfacesModularizationRobustnessDesign Details 3/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Informal approaches to correctness  Correctness by Informal Methods Simplify and modularize designs until they are convincing.  Informal Approaches  Informal approaches are based on the common sense idea that before we can proclaimed a design to be correct, we have to understand it completely.  Informal approaches require that design must be  Readable (to enhance understanding)  Modular (to deal with complexity) Correctness InterfacesModularizationRobustnessDesign Details 4/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Sufficient Designs: Terminology and Rationale A design sufficient to implement the requirements. a correct design Sometimes called … the design must be entirely understandable It follows that … the design very modular A common way to achieve this is to make … Minimum goal: Correctness InterfacesModularizationRobustnessDesign Details 5/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Formal approaches to correctness  Formal approaches  Keeping variable changes under tight control  It can be achieved through invariants  Invariants are unchanging relationships among variable values  Invariants used at class level are class invariants  Examples:  “length>=0”  “length * breadth == area” Correctness InterfacesModularizationRobustnessDesign Details 6/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Invariants for Class Automobile -- with variables mileage, VehicleID, value, originalPrice, and type : 1) mileage > 0 2) mileage < ) vehicleID has at least 8 characters 4) value >= -300  ($300 is the disposal cost of a worthless automobile) 5) originalPrice >= 0 6) ( type == “REGULAR” && value <= originalPrice ) ||  ( type == “VINTAGE” && value >= originalPrice ) Correctness InterfacesModularizationRobustnessDesign Details 7/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Formal approaches to correctness (cont.)  Some guidelines for achieving correctness at coding level  Make variables private  Change the variables values only through public accessor methods  Accessors can be coded to maintain invariants Correctness InterfacesModularizationRobustnessDesign Details 8/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Interfaces to modules  Interfaces: collections of function prototypes: Make designs more understandable.  Modularity  Modularization is key to assess the correctness of a design  A module can be either a class or a package of classes  An interface is a set of functions forms (or prototypes) Correctness Interfaces ModularizationRobustnessDesign Details 9/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Interfaces to modules  Interfaces to classes  When a class supports many methods, it is often beneficial to group them into several interfaces  Grouping allows reuse Shipment setVehicle() perishable() getWidth() printRoute() describeType() getLength() getDuration() setType() Correctness Interfaces ModularizationRobustnessDesign Details 10/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Introducing Interfaces Shipment Dimensions getWidth() getLength() getWeight() TransportationMeans getDuration() setVehicle() printRoute() GoodsType describeType() setType() perishable() Shipment Dimensions TransportationMeans GoodsType Original form Forms using interfaces Shipment setVehicle() perishable() getWidth() printRoute() describeType() getLength() getDuration() setType() Correctness Interfaces ModularizationRobustnessDesign Details 11/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Interfaces to modules  Interfaces to Packages  Interface to package is different idea than an interface to a class  Provide an interface for a designated object of a class in the package or  Define a class in a package and define its interface as static methods Correctness Interfaces ModularizationRobustnessDesign Details 12/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Package Interfaces Pricing purchases Furniture Clothing Appliance Selection ClothingTryout «singleton» PurchasesIF Correctness Interfaces ModularizationRobustnessDesign Details 13/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Participant- services Conversation- services Example of Package Interfaces Conversation chatServer chatClient Display ConversationManager ClientComm ServerComm billing AccountingBill Financial Message- reception Correctness Interfaces ModularizationRobustnessDesign Details 14/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Sec Modularization  To modularize an object-oriented application  Create packages at the higher level  Create classes at the lower level  Choosing classes (Two kinds of classes)  Domain classes  classes that pertain to the specific application under design.  Can be obtained from the sequence diagrams of use cases.  Non-domain classes  generalization of domain classes CorrectnessInterfaces Modularization RobustnessDesign Details 15/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Domain vs. Non-Domain Classes  Domain classes: Particular to the application  Examples: BankCustomer, BankTransaction, Teller  Typically not GUI classes  Sufficient to classify all requirements  Non-Domain classes: Generic  Examples: abstract classes, utility classes  Arise from design and implementation considerations CorrectnessInterfaces Modularization RobustnessDesign Details 16/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Modularization  Choosing packages  Essential part of choosing an application ’ s architecture  Decompose application into a set of packages (typically 3 to 10) CorrectnessInterfaces Modularization RobustnessDesign Details 17/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Robustness  The ability to handle anomalous situations  Incorrect user input  Faulty data communication  Developer errors  Verifying Input.  Robustness is promoted by verifying data values before using them.  Check all inputs for constraints. It can include:  Type verification, Preconditions, Invariants, Postconditions  Initialize variables and objects at declaration/ creation time improve robustness CorrectnessInterfacesModularization Robustness Design Details 18/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Sources of Errors  Robustness --- ability to handle anomalous situations even in the presence of errors  Sources of error:  Faulty input  User input  Input, not from users  Data communication  Function calls made by other applications  Developer errors  Faulty design  Faulty implementation CorrectnessInterfacesModularization Robustness Design Details 19/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Constraints on Parameters Example: int computeArea( int aLength, int aBreadth ) { … }  Capture parameter constraints in classes if feasible int computeArea( RectangleDimension a RectangleDimension )  Specify all parameter constraints in method comments aLength > 0 and aBreadth > 0 and aLength >= aBreadth  Callers obey explicit requirements on parameters  Problem is method programmers have no control over callers  Check constraints first within the method code if( aLength <= 0 ) ……  Throw exception if this is a predictable occurrence  Otherwise abort if possible  Otherwise return default if it makes sense in context  And generate warning or log to a file CorrectnessInterfacesModularization Robustness Design Details 20/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Wrapping Parameters (to handle constraints) Replace int computeArea( int aLength, int aBreadth ) {..} with int computeArea( Rectangle aRectangle ) {..} -- where class Rectangle { … Rectangle( int aLength, int aBreadth ) { if( aLength > 0 ) this.length = aLength; else ….. } … } CorrectnessInterfacesModularization Robustness Design Details 21/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Design Details  How much is enough?  Most detailed design provide  Class, sequence, state, and activity models  Provide activity diagram or pseudocode for complex methods only  Code before design?  Depends of the nature of the task and the experience of the programmer.  Design details through a graph Sec 4.3 CorrectnessInterfacesModularizationRobustness Design Details 22/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser How Much Design Detail Before Initial Coding? Very simple 0% Recommended % of design detail before starting to code Very complex 100% Type of application Inexperienced designer Experienced designer Diminishing ability of designer to envisage consequences of design decision. CorrectnessInterfacesModularizationRobustness Design Details 23/24

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Summary of This Chapter  Correctness of a Design or Code  Supports the requirements  In general, many correct designs exist  Robustness of a Design or Code  Absorbs errors  -- of the user  -- of developers  is promoted by enforcing intentions. CorrectnessInterfacesModularizationRobustnessDesign Details 24/24