Karlstad University Computer Science Design Contracts and Error Management External and internal errors and their contracts.

Slides:



Advertisements
Similar presentations
Chapter 17 Failures and exceptions. This chapter discusses n Failure. n The meaning of system failure. n Causes of failure. n Handling failure. n Exception.
Advertisements

Testing Relational Database
Design by Contract.
Exceptions CSE301 University of Sunderland Harry Erwin, PhD.
Test process essentials Riitta Viitamäki,
Karlstad University Computer Science Design Contracts and Error Management Design Contracts and Errors A Software Development Strategy Eivind J. Nordby.
Exceptions and Exception Handling Carl Alphonce CSE116.
Software Construction 1 ( ) First Semester Dr. Samer Odeh Hanna (PhD) Office: IT 327.
Microsoft VB 2005: Reloaded, Advanced Chapter 5 Input Validation, Error Handling, and Exception Handling.
Error Management with Design Contracts Karlstad University Computer Science Error Management with Design Contracts Eivind J. Nordby, Martin Blom, Anna.
1 Design by Contract Building Reliable Software. 2 Software Correctness Correctness is a relative notion  A program is correct with respect to its specification.
Exceptions and Exception Handling (1) Carl Alphonce CSE116.
On the Relation between Design Contracts and Errors Karlstad University Computer Science On the Relation Between Design Contracts and Errors A Software.
Software Testing and Quality Assurance
© Copyright Eliyahu Brutman Exceptions. © Copyright Eliyahu Brutman Exceptions and Design Patterns - 2 Introduction to Exception Handling Definition:
CS-550 (M.Soneru): Recovery [SaS] 1 Recovery. CS-550 (M.Soneru): Recovery [SaS] 2 Recovery Computer system recovery: –Restore the system to a normal operational.
Improved software quality through semantic descriptions (Skutt) Karlstad University Dept. of Computer Science Semla Design Method for use in.
Karlstad University Computer Science Design Contracts and Error Management Design Contracts and Errors A Software Development Strategy (anpassad för PUMA)
Improved software quality through semantic descriptions (Skutt) Karlstad University Dept. of Computer Science Semla Design Method for use in.
CSC 395 – Software Engineering Lecture 21: Overview of the Term & What Goes in a Data Dictionary.
Advanced Java Course Exception Handling. Throwables Class Throwable has two subclasses: –Error So bad that you never even think about trying to catch.
1 © Wolfgang Pelz Design by Contract Design by Contract™ Based on material drawn from: Bertrand.
Copyright Arshi Khan1 System Programming Instructor Arshi Khan.
Introduction to Java Chapter 11 Error Handling. Motivations When a program runs into a runtime error, the program terminates abnormally. How can you handle.
Computer Science 340 Software Design & Testing Design By Contract.
CPSC 252 Exception Handling Page 1 Exceptions and exception handling Client programmers can make errors using a class attempting to dequeue an item from.
Object Oriented Programming
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
© 2012 IBM Corporation Rational Insight | Back to Basis Series Chao Zhang Unit Testing.
A Pragmatic Application of PbC Karlstads University Computer Science A pragmatic Application of Programming by Contract Martin Blom / Eivind Nordby Karlstad.
SWE 619 © Paul Ammann Procedural Abstraction and Design by Contract Paul Ammann Information & Software Engineering SWE 619 Software Construction cs.gmu.edu/~pammann/
Exceptions Handling Exceptionally Sticky Problems.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Concurrency Control. Objectives Management of Databases Concurrency Control Database Recovery Database Security Database Administration.
Exceptions cs1043. Program Exceptions When a program detects an error, what should it do? – Nothing, simply allow the program to fail. – Implement a course.
Exception Handling Programmers must deal with errors and exceptional situations: User input errors Device errors Empty disk space, no memory Component.
© Paul Ammann, 2008 Design by Contract Paul Ammann CS/SWE 332.
Computer Science 209 Software Development Handing Errors and Creating Documentation.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
SWE 4743 Abstract Data Types Richard Gesick. SWE Abstract Data Types Object-oriented design is based on the theory of abstract data types Domain.
Outsourcing, subcontracting and COTS Tor Stålhane.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 14 Event-Driven Programming with Graphical User Interfaces.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
Exceptions Lecture 11 COMP 401, Fall /25/2014.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 10: Programming Exceptionally.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
Exception and Exception Handling. Exception An abnormal event that is likely to happen during program is execution Computer could run out of memory Calling.
ECE122 L23: Exceptions December 6, 2007 ECE 122 Engineering Problem Solving with Java Lecture 24 Exceptions.
Improved software quality through semantic descriptions (Skutt) Karlstad University Dept. of Computer Science Semla Design Method for use in.
Chapter 29: Program Security Dr. Wayne Summers Department of Computer Science Columbus State University
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Lecture 18B Exception Handling and Richard Gesick.
1 Team Skill 3 Defining the System Part 1: Use Case Modeling Noureddine Abbadeni Al-Ain University of Science and Technology College of Engineering and.
Java Exceptions a quick review….
PREPARED BY G.VIJAYA KUMAR ASST.PROFESSOR
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
MICROPROCESSOR BASED SYSTEM DESIGN
Coupling and Cohesion 1.
Handling Exceptionally Sticky Problems
Software Development Handing Errors and Creating Documentation
CSC 143 Error Handling Kinds of errors: invalid input vs programming bugs How to handle: Bugs: use assert to trap during testing Bad data: should never.
Exception Handling Imran Rashid CTO at ManiWeber Technologies.
Chapter 29: Program Security
Ninth step for Learning C++ Programming
Tenth step for Learning C++ Programming
Handling Exceptionally Sticky Problems
Computer Science 340 Software Design & Testing
Error Handling in Java Servlets
Design Contracts and Errors A Software Development Strategy
Presentation transcript:

Karlstad University Computer Science Design Contracts and Error Management External and internal errors and their contracts

Karlstad University Computer Science Design Contracts and Error Management Contract principles, page 2 A system part exposes interfaces –External or internal External and Internal Interfaces System part Supplier Internal interface External interface

Karlstad University Computer Science Design Contracts and Error Management Contract principles, page 3 Some possible sources of external errors External Interfaces Software Components The System Hardware Components Data Bases Error End Users Other System

Karlstad University Computer Science Design Contracts and Error Management Contract principles, page 4 Some possible sources of internal errors Internal Interfaces Programmers Error Program Fault Violation Designers Error Design Fault Violation The system

Karlstad University Computer Science Design Contracts and Error Management Contract principles, page 5 External errors –Committed by end users or external systems Databases, external components, hardware –Cause violation of external interfaces Internal errors –Committed by developers –Result in faults in the software –Cause violation of internal interfaces External and Internal Errors On a permanent basis, consistent until the software is corrected On a per use basis, varying from case to case

Karlstad University Computer Science Design Contracts and Error Management Contract principles, page 6 External errors –Correct input cannot be assured –wrong input should be handled and the user informed –Best managed by weak contracts Internal errors –Correct input can be assured –System faults should be detected And corrected by the responsible author –Best managed by strong contracts Correspondence Contracts  Errors

Karlstad University Computer Science Design Contracts and Error Management What happens if the precondition is not satisfied? Can we support internal error detection?

Karlstad University Computer Science Design Contracts and Error Management Contract principles, page 8 Different Strategies for Handling Violated Preconditions Since the client has not kept its part of the contract, the supplier has no obligations whatsoever The supplier can do whatever it wants Two possible strategies –Do nothing special try to perform the task in the normal way hope that the system will die :-) –Trap the violation and make the system die exit (or throw an undocumented runtime exception) possibly dump an error code to a log file

Karlstad University Computer Science Design Contracts and Error Management Contract principles, page 9 An Example of Handling Precondition Violations getElement method in a list –The precondition states that position should be within the boundaries of the list size. –If the position is not ok, the system will still survive as long as position is within the array boundaries. –One approach is to trap the violation and make the system die to notify the developer to correct the error in the client code // Pre: 0 <= position < size() // Post: result = the element at position // ’position’ Object getElement(int position) { if(Compilation.ASSERT_IS_ON) Assert.isTrue(positionOK(position)); return elements[position]; }

Karlstad University Computer Science Design Contracts and Error Management Contract principles, page 10 Do Not Try to Handle the Error Do not handle errors and allow the system to go on, this makes things worse –The client should not be aware of any exceptions that might be thrown. It could be tempted to catch it and thereby allow the error to live on. –Documenting an error exception that is not part of the contract would actually implement a different contract than the one specified for the method. What about making it part of the contract? Trapping the violation - The client is not aware of the test –From the client’s point of view, there is no test of the precondition. –The test can be removed without affecting the contract since it is not part of the contract For the client, there is no recovery from the error –The only measure taken if the precondition is violated is to exit the system. –It is an error trap, not an error handling mechanism.

Karlstad University Computer Science Design Contracts and Error Management Contract principles, page 11 Rules for Precondition Violation Traps The trap should be completely transparent to the client –No return value to test or exception to catch –A trap causes the program to die when it detects an error The programmer should develop the client code without resorting to the traps –The traps may be disabled or enabled without his knowledge The supplier code should produce the same result with a trap as without it –The program may be run with traps enabled or disabled –The trap should not affect the behavior of the system in any way –In particular, the trap should not have any effect on the state.