Chapter 4: Design Principles I: Correctness and Robustness



Similar documents
Software Engineering Techniques

Software Design Document (SDD) Template

UML TUTORIALS THE USE CASE MODEL

Software Design. Software Design. Software design is the process that adds implementation details to the requirements.

Chapter 1: Key Concepts of Programming and Software Engineering

Design by Contract beyond class modelling

Adapting C++ Exception Handling to an Extended COM Exception Model

Acknowledgement. Software Engineering. CS 3141: Team Software Project Introduction

4.4 What is a Requirement? 4.5 Types of Requirements. Functional Requirements

4.1. Title: data analysis (systems analysis) Annotation of educational discipline: educational discipline includes in itself the mastery of the

Introducing Formal Methods. Software Engineering and Formal Methods

On the Relation between Design Contracts and Errors: A Software Development Strategy

Software Component Specification Using Design by Contract

BCS HIGHER EDUCATION QUALIFICATIONS Level 6 Professional Graduate Diploma in IT. March 2013 EXAMINERS REPORT. Software Engineering 2

Software Refactoring using New Architecture of Java Design Patterns

Introduction and Overview

Programming by Contract. Programming by Contract: Motivation. Programming by Contract: Preconditions and Postconditions

CSE 308. Coding Conventions. Reference

Use-Case Analysis. ! What is it? ! From where did it come? ! Now part of UML

Flowcharting, pseudocoding, and process design

Engineering Process Software Qualities Software Architectural Design

Course Title: Software Development

Java Programming (10155)

CS 389 Software Engineering. Lecture 2 Chapter 2 Software Processes. Adapted from: Chap 1. Sommerville 9 th ed. Chap 1. Pressman 6 th ed.

Boogie: A Modular Reusable Verifier for Object-Oriented Programs

Software Requirements. Descriptions and specifications of a system. Ian Sommerville 2000 Software Engineering, 6th edition.

Software Process for QA

Software Development Life Cycle (SDLC)

Integration of an open source rule engine to enhance the IHTSDO Workbench testing

Specification and Analysis of Contracts Lecture 1 Introduction

Computer Programming I

Structure of Presentation. Stages in Teaching Formal Methods. Motivation (1) Motivation (2) The Scope of Formal Methods (1)

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Programming Language Constructs as Basis for Software Architectures

Software Development: The Waterfall Model

Curriculum Map. Discipline: Computer Science Course: C++

Quotes from Object-Oriented Software Construction

Application development = documentation processing

CIS 544 Advanced Software Design and Development. Project Management System. Oreoluwa Alebiosu

22C:22 (CS:2820) Object-Oriented Software Development

Lecture 1: Introduction to Software Quality Assurance

Introduction to Programming System Design. CSCI 455x (4 Units)

Keywords Aspect-Oriented Modeling, Rule-based graph transformations, Aspect, pointcuts, crosscutting concerns.

Project Management Planning

CSC 342 Semester I: H ( G)

Formal Specification and Verification of Avionics Software

Case studies: Outline. Requirement Engineering. Case Study: Automated Banking System. UML and Case Studies ITNP090 - Object Oriented Software Design

LEVERAGING DEDUCTIVE VERIFICATION IN INDUSTRIAL CONTEXTS

Logistics. Software Testing. Logistics. Logistics. Plan for this week. Before we begin. Project. Final exam. Questions?

SilkTest Workbench. Getting Started with.net Scripts

Overview. What is software testing? What is unit testing? Why/when to test? What makes a good test? What to test?

TECHNICAL UNIVERSITY OF CRETE DATA STRUCTURES FILE STRUCTURES

Software Engineering. Software Development Process Models. Lecturer: Giuseppe Santucci

Master of Science in Software Engineering Student Guide

Computer Science 210: Data Structures. Searching

Lecture 3 Topics on Requirements Engineering

2667A - Introduction to Programming

Questions? Assignment. Techniques for Gathering Requirements. Gathering and Analysing Requirements

Chapter 7: Software Engineering

Chapter 24 - Quality Management. Lecture 1. Chapter 24 Quality management

Chapter 13: Program Development and Programming Languages

Chapter 2: Algorithm Discovery and Design. Invitation to Computer Science, C++ Version, Third Edition

The Workflow Management Coalition Specification Workflow Management Coalition Terminology & Glossary

Modern Systems Analysis and Design

Acme vs PDDL: support for dynamic reconfiguration of software architectures

Agent-Oriented Software Engineering

To introduce software process models To describe three generic process models and when they may be used

Reverse Literate Programming

Requirements engineering

Software Engineering. Software Processes. Based on Software Engineering, 7 th Edition by Ian Sommerville

THE BCS PROFESSIONAL EXAMINATIONS Diploma. April 2006 EXAMINERS REPORT. Systems Design

Software Requirements Specification of A University Class Scheduler

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

Volume I, Section 4 Table of Contents

ATV Data Link Simulator: A Development based on a CCSDS Layers Framework

CS 106 Introduction to Computer Science I

Algorithms, Flowcharts & Program Design. ComPro

Software testing. Objectives

Decomposition into Parts. Software Engineering, Lecture 4. Data and Function Cohesion. Allocation of Functions and Data. Component Interfaces

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

Software Engineering Reference Framework

A Capability Maturity Model (CMM)

Formally speaking: How to apply OCL

Introduction to Software Paradigms & Procedural Programming Paradigm

The Rules 1. One level of indentation per method 2. Don t use the ELSE keyword 3. Wrap all primitives and Strings

Lecture 1: Introduction

Chapter 4: Tools of Modern Systems Analysis

Apache Web Server Execution Tracing Using Third Eye

PL/SQL Practicum #2: Assertions, Exceptions and Module Stability

What is a life cycle model?

Software Life Cycle. Management of what to do in what order

Software Processes. The software process. Generic software process models. Waterfall model. Waterfall model phases

Software Architecture Document

Software Testing & Analysis (F22ST3): Static Analysis Techniques 2. Andrew Ireland

Ch 7-1. Object-Oriented Programming and Classes

Automated Program Behavior Analysis

Higher National Unit specification. General information. Software Development: Analysis and Design (SCQF level 7) Unit code: HA4C 34.

Transcription:

Chapter 4: Design Principles I: Correctness and Robustness King Fahd University of Petroleum & Minerals SWE 316: Software Design & Architecture Semester: 072

Objectives To introduce two design principles Correctness Robustness SWE 316 (072) Chapter 4: Design Principles I 2

Correctness Software design must satisfy the requirements for the application The more specific a question, the more precisely we can verify the correctness of a design that answers it Precise and imprecise questions: What number adds to 3 to get 5? What bridge design gets cars from point A to point B? Correctness of design usually means sufficient design SWE 316 (072) Chapter 4: Design Principles I 3

Approaches to Correctness How can we know that a design is correct or even sufficient? Informal approaches To be convinced that the design covers the required functionality. Formal approaches Involve applying mathematical logic to analyzing the way in which the variables change Usually applied when the design enters the detailed stage SWE 316 (072) Chapter 4: Design Principles I 4

Informal Approaches to Correctness 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) SWE 316 (072) Chapter 4: Design Principles I 5

Sufficient Designs: Terminology and Rationale SWE 316 (072) Chapter 4: Design Principles I 6

Key Concept: Correctness by Informal Methods Simplify and modularize designs until they are convincing. A famous apology (Pascal & Shaw): I didn t have time to write a short letter, so I wrote a long one SWE 316 (072) Chapter 4: Design Principles I 7

Formal Approaches to Correctness 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 SWE 316 (072) Chapter 4: Design Principles I 8

Example: Invariants for Class Automobile With variables mileage, vehicleid, value, originalprice, and type: mileage 0 mileage < 1000000 vehicleid has at least 8 characters value -300 ($300 is the disposal cost of a worthless automobile) originalprice 0 SWE 316 (072) Chapter 4: Design Principles I 9

Interfaces to Modules Modularization is a key way 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). A module s interfaces define its uses. SWE 316 (072) Chapter 4: Design Principles I 10

Interfaces to Classes When a class supports many methods, it is often beneficial to group them into several interfaces Grouping allows reuse SWE 316 (072) Chapter 4: Design Principles I 11

Example SWE 316 (072) Chapter 4: Design Principles I 12

Interfaces to Packages Interface to package is different idea than an interface to a class Two ways: 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 SWE 316 (072) Chapter 4: Design Principles I 13

Example 1 SWE 316 (072) Chapter 4: Design Principles I 14

Example 2 SWE 316 (072) Chapter 4: Design Principles I 15

Modularization To modularize an object-oriented application Create packages at the higher level Create classes at the lower level Choosing classes: Two general kinds of classes Domain classes: classes that pertain to the specific application under design. Examples: BankCustomer, BankTransaction, Teller Non-domain classes: generic Examples: abstract classes, utility classes Arise from design and implementation considerations SWE 316 (072) Chapter 4: Design Principles I 16

Modularization (Cont d) Choosing packages Essential part of choosing an application s architecture Decompose application into a set of packages (typically 3 to 10) SWE 316 (072) Chapter 4: Design Principles I 17

Refactoring for Correctness and Sufficiency Refactoring: revising the design and implementation to accommodate additional requirements Extreme programming SWE 316 (072) Chapter 4: Design Principles I 18

Refactoring for Correctness and Sufficiency (Cont d) Possible refactoring methods: Promoting a primitive attribute to class Class selection is the process of identifying a useful concept and defining a class for it To accommodate increased scope, refactoring will be needed Example: Automobile and mileage Introducing abstract classes or interfaces Use abstraction when the application contains several classes having significant commonality. SWE 316 (072) Chapter 4: Design Principles I 19

Robustness 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 SWE 316 (072) Chapter 4: Design Principles I 20

Verifying Input (Ensuring Environmental Robustness) Check all inputs for constraints. It can include: Type verification Preconditions Invariants Postconditions Initializing variables and objects at declaration/creation time improve robustness SWE 316 (072) Chapter 4: Design Principles I 21

Parameter Passing Techniques to Improve Robustness Ensure that methods are called safely. Example: int computearea( int alength, int abreadth ) { } Specify all parameter constraints in method comments alength > 0 and abreadth > 0 and alength >= abreadth Callers obey explicit requirements on parameters Problem is that 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 SWE 316 (072) Chapter 4: Design Principles I 22

Capturing Parameters in a Class A good way to handle recurring constraints on parameters is to capture (wrap) the parameters in a class Example: 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.. } } SWE 316 (072) Chapter 4: Design Principles I 23

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 on the nature of the task and the experience of the programmer. SWE 316 (072) Chapter 4: Design Principles I 24

How Much Design Detail Before Initial Coding? SWE 316 (072) Chapter 4: Design Principles I 25

Summary 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 SWE 316 (072) Chapter 4: Design Principles I 26