ERROR HANDLING AND DEBUGGING

Slides:



Advertisements
Similar presentations
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Advertisements

Exception Handling – illustrated by Java mMIC-SFT November 2003 Anders P. Ravn Aalborg University.
Exceptions Ensuring program reliability. Program correctness The term program correctness refers to a program’s working as advertised; that is, it produces.
Exceptions Don’t Frustrate Your User – Handle Errors KR – CS 1401 Spring 2005 Picture – sysprog.net.
Exception Handling Chapter 15 2 What You Will Learn Use try, throw, catch to watch for indicate exceptions handle How to process exceptions and failures.
© 2004 Pearson Addison-Wesley. All rights reserved10-1 Chapter 10 : Exceptions Intermediate Java Programming Summer 2007.
C# Programming: From Problem Analysis to Program Design1 Debugging and Handling Exceptions C# Programming: From Problem Analysis to Program Design 3 rd.
Exceptions and Exception Handling Carl Alphonce CSE116 March 9, 2007.
Chapter 8Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 8 l Basic Exception Handling »the mechanics of exceptions l.
Chapter 11 Debugging and Handling Exceptions
COP 2800 Lake Sumter State College Mark Wilson, Instructor.
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
Microsoft VB 2005: Reloaded, Advanced Chapter 5 Input Validation, Error Handling, and Exception Handling.
Objectives Understanding what an exception is Understanding the heirarchy of exception classes Learn the types of exception and how to catch and handle.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 8 Exception Handling Sections 1-5, 7.
16-Jun-15 Exceptions. Errors and Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a null.
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Exceptions. Errors and Exceptions An error is a bug in your program –dividing by zero –going outside the bounds of an array –trying to use a null reference.
Exception Handling An Exception is an indication of a problem that occurs during a program’s execution. Exception handling enables the programmer to create.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 8 Exception Handling Sections 1-5, 7.
Advanced Java Course Exception Handling. Throwables Class Throwable has two subclasses: –Error So bad that you never even think about trying to catch.
Exceptions. Many problems in code are handled when the code is compiled, but not all Some are impossible to catch before the program is run  Must run.
Java Software Solutions Foundations of Program Design Sixth Edition
Exception Handling. Exceptions and Errors When a problem encounters and unexpected termination or fault, it is called an exception When we try and divide.
June 14, 2001Exception Handling in Java1 Richard S. Huntrods June 14, 2001 University of Calgary.
Object Oriented Programming
06 Exception Handling. 2 Contents What is an Exception? Exception-handling in Java Types of Exceptions Exception Hierarchy try-catch()-finally Statement.
CIS 270—Application Development II Chapter 13—Exception Handling.
VB.Net - Exceptions Copyright © Martin Schray
1 Software Construction and Evolution - CSSE 375 Exception Handling - Principles Steve Chenoweth, RHIT Above – Exception handling on the ENIAC. From
Software Development. Software Developers Refresher A person or organization that designs software and writes the programs. Software development is the.
Introduction to Exception Handling and Defensive Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Exceptions in Java. Exceptions An exception is an object describing an unusual or erroneous situation Exceptions are thrown by a program, and may be caught.
Data Structures Using Java1 Chapter 2 Inheritance and Exception Handling.
Chapter 12 Handling Exceptions and Events. Chapter Objectives Learn what an exception is Become aware of the hierarchy of exception classes Learn about.
Exceptions and Assertions Chapter 15 – CSCI 1302.
Software Engineering Saeed Akhtar The University of Lahore.
Exception Handling in Java Topics: Introduction Errors and Error handling Exceptions Types of Exceptions Coding Exceptions Summary.
Error Handling Tonga Institute of Higher Education.
Programming & Debugging. Key Programming Issues Modularity Modifiability Ease of Use Fail-safe programming Style Debugging.
Java Programming: Exceptions1 Exceptions Reference: java.sun.com/docs/books/tutorial/essential/exceptions/
Exceptions Lecture 11 COMP 401, Fall /25/2014.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Lecture10 Exception Handling Jaeki Song. Introduction Categories of errors –Compilation error The rules of language have not been followed –Runtime error.
ECE122 L23: Exceptions December 6, 2007 ECE 122 Engineering Problem Solving with Java Lecture 24 Exceptions.
Introduction to Exceptions in Java CS201, SW Development Methods.
Agenda Introduction Errors and Exception Exception Hierarchy Classification of Exceptions Built in Exceptions Exception Handling in Java User defined.
Exceptions in the Java programming language J. W. Rider.
Eighth Lecture Exception Handling in Java
Java Exceptions a quick review….
Debugging and Handling Exceptions
Tirgul 13 Exceptions 1.
Exceptions 10-Nov-18.
Advanced Programming Behnam Hatami Fall 2017.
CNS 3260 C# .NET Software Development
ATS Application Programming: Java Programming
Chapter 12 Exception Handling
Exceptions Problems in a Java program may cause exceptions or errors representing unusual or invalid processing. An exception is an object that defines.
Exception Handling Chapter 9 Edited by JJ.
Part B – Structured Exception Handling
Chapter 13: Construction
Lecture 11 Objectives Learn what an exception is.
Java Exceptions Dan Fleck CS211.
Exceptions (part 2) December 3, 2007 ComS 207: Programming I (in Java)
Exceptions 10-May-19.
CMSC 202 Exceptions 2nd Lecture.
Exception Handling.
Java Programming: From Problem Analysis to Program Design, 4e
Presentation transcript:

ERROR HANDLING AND DEBUGGING 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 1

Objectives Write a program that uses structured exceptions. Compare the exception hierarchy in Java with the exception hierarchy in .NET Use a Try...Catch...Finally construct. Throw exceptions Create custom exceptions Perform debugging techniques. Identify the principles of debugging Identify debugging strategies Set breakpoints and step through code Use the call stack to isolate a problem Compare the following types of testing: Desk checking, Unit testing, Integration testing, Code reviews. Compare and contrast black box, white box, and architectural tests Describe the purpose of unit testing Describe the purpose of integration testing Design tests 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 2

Exception Class Hierarchy (Java) java.lang java.io Throwable Interface Serializable Exception Error RuntimeException 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 3

Exception Class Hierarchy .NET System.Object System.Exception ISerializable System.ApplicationException System.SystemException 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 4

Try…Catch…Finally Try Catch Finally Code that might throw an exception Code to handle the exception Finally Cleanup code to execute when exit is normal or because of exception 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 5

Standard Exception Handling Options Log exception Ask for input Use default or alternate value Forward control somewhere else Convert the exception Ignore the exception Retry the action that caused the exception Take a recovery action Prepare to terminate 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 6

Dos and Don’ts Dos Don’t Handle exceptions if you can Handle specific exceptions specifically Log exceptions Convert exceptions to a business context Don’t Ignore an exception Use blanket exception handling Convert a specific exception to a general exception Handle an exception you could avoid 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 7

Custom Exceptions (Java) Define the exception class public class MyException extends Exception Declare the methods as “throws CustomerException” public void MyMethod () throws MyException Throw the exception Throw new MyException(“Problem”) 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 8

Custom Exceptions (VB.NET) Define the exception class Public Class MyException Inherits Exception Throw the exception Throw new MyException(“Problem”) 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 9

Common Misconceptions about Testing Developers should do no testing Developers should do all the testing You just need to do one thing to test You can fully test an application 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 10

Types of Testing Black box White box Architectural Testers and users Developers Architectural Load test Performance test Security test Stress test Usability test 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 11

Improving testability Modularize code Use encapsulation and interfaces Define services to relate to business behavior Define methods that capture State Flow 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 12

Moving to Integration Testing Different coding styles might present an issue More use of abstraction and encapsulation Context and invocation order become important 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 13

Debugging Principles Know your system Repeatability Understand the differences between the bug and your system Debugging requires testing 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 14

Debugging Strategies Reproduce the bug Test around the bug Look for differences between systems where the bug occurs and where it doesn’t Narrow the scope Identify the “Point of Departure” Brainstorm with the group Look for similar problems in bug database Look for patterns over time Filter your system’s output Simulate system behavior Monitor the system 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 15

Debugging Techniques Breakpoints Stepping through code Watch window Step into Step over Watch window Call stack 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 16

Summary In this unit, students learned: How to perform structured error handling. How to create and throw exceptions. Methods for testing an application. Debugging techniques. 9/27/2019© 2006 ITT Educational Services Inc. Structured Programming: Unit 4 Slide 17