Debugging. Compile problems Read the whole complaint! Runtime problems –Exceptions –Incorrect behavior.

Slides:



Advertisements
Similar presentations
Test process essentials Riitta Viitamäki,
Advertisements

Detecting Bugs Using Assertions Ben Scribner. Defining the Problem  Bugs exist  Unexpected errors happen Hardware failures Loss of data Data may exist.
Scope and Lifespan of Identifiers. Every function has a scope What does that mean? That means that every identifier that is created in a function (that’s.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Concolic Modularity Testing Derrick Coetzee University of California, Berkeley CS 265 Final Project Presentation.
API Design CPSC 315 – Programming Studio Fall 2008 Follows Kernighan and Pike, The Practice of Programming and Joshua Bloch’s Library-Centric Software.
Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
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.
Intermediate Java II Sakir YUCEL MISM/MSIT Carnegie Mellon University Lecture: Exception Handling Slides adapted from Prof. Steven Roehrig.
Lecture 7 Model Development and Model Verification.
16/27/2015 3:38 AM6/27/2015 3:38 AM6/27/2015 3:38 AMTesting and Debugging Testing The process of verifying the software performs to the specifications.
© S. Demeyer, S. Ducasse, O. Nierstrasz Chapter.1 Unit Testing Explained How to support changes? How to support basic but synchronized documentation?
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
Fall 2007CS 225 Program Correctness and Efficiency Chapter 2.
Dr. Pedro Mejia Alvarez Software Testing Slide 1 Software Testing: Building Test Cases.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
Software Quality Chapter Software Quality  How can you tell if software has high quality?  How can we measure the quality of software?  How.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Dr Andy Brooks1 FOR0383 Software Quality Assurance Lecture 1 Introduction Forkröfur/prerequisite: FOR0283 Programming II Website:
Slides Credit Umair Javed LUMS Web Application Development.
Coding Methodology How to Design Code. © 2005 MIT-Africa Internet Technology Initiative Pay Attention to Detail When implementing or using APIs details.
DEBUGGING CHAPTER Topics  Getting Started with Debugging  Types of Bugs –Compile-Time Bugs –Bugs Attaching Scripts –Runtime Errors  Stepping.
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.
หลักการโปรแกรม เพื่อแก้ปัญหาโดยใช้คอมพิวเตอร์
Computer Science and Engineering College of Engineering The Ohio State University Interfaces The credit for these slides goes to Professor Paul Sivilotti.
Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source.
2_Testing Testing techniques. Testing Crucial stage in the software development process. Significant portion of your time on testing for each programming.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
23-Oct-15 Abstract Data Types. 2 Data types A data type is characterized by: a set of values a data representation, which is common to all these values,
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
Best Practices. Contents Bad Practices Good Practices.
Debugging Strategies from Software Carpentry. Agan's Rules Many people make debugging harder than it needs to be by: Using inadequate tools Not going.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Making Good Code AKA: So, You Wrote Some Code. Now What? Ray Haggerty July 23, 2015.
Definition of Terms Software/Programs Programs that directs the operation of a computer system Set of instructions Codes Programming Process of planning,
Debugging and Profiling With some help from Software Carpentry resources.
CSC 142 D 1 CSC 142 Instance methods [Reading: chapter 4]
What is Testing? Testing is the process of finding errors in the system implementation. –The intent of testing is to find problems with the system.
Programming with Assertions © Allan C. Milne v
Chapter 10 Classes and Objects In-Depth. Chapter 10 A class provides the foundation for creating specific objects, each of which shares the general attributes,
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Debugging Computer Networks Sep. 26, 2007 Seunghwan Hong.
Design - programming Cmpe 450 Fall Dynamic Analysis Software quality Design carefully from the start Simple and clean Fewer errors Finding errors.
Error messages 25-Apr-17.
School of Computer Science & Information Technology G6DICP - Lecture 6 Errors, bugs and debugging.
Objects First With Java A Practical Introduction Using BlueJ Well-behaved objects 2.1.
Testing CSE 160 University of Washington 1. Testing Programming to analyze data is powerful It’s useless (or worse!) if the results are not correct Correctness.
SWE 4743 Abstract Data Types Richard Gesick. SWE Abstract Data Types Object-oriented design is based on the theory of abstract data types Domain.
Error Handling Tonga Institute of Higher Education.
Programming & Debugging. Key Programming Issues Modularity Modifiability Ease of Use Fail-safe programming Style Debugging.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Defining Classes I Part B. Information hiding & encapsulation separate how to use the class from the implementation details separate how to use the class.
Chapter 1 The Phases of Software Development. Software Development Phases ● Specification of the task ● Design of a solution ● Implementation of solution.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
Design by Contract. The Goal Ensure the correctness of our software (correctness) Recover when it is not correct anyway (robustness) Correctness: Assertions.
Conditionals, Block Statements, Style
More Sophisticated Behavior
Chapter 8 – Software Testing
Testing and Debugging.
Testing UW CSE 160 Winter 2017.
The Pseudocode Programming Process
Debugging CMSC 202.
2_Testing Testing techniques.
Chapter 18 Software Testing Strategies
Testing UW CSE 160 Winter 2016.
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
BugHint: A Visual Debugger Based on Graph Mining
ICT Gaming Lesson 2.
For Tutors Introduce yourself.
Presentation transcript:

Debugging

Compile problems Read the whole complaint! Runtime problems –Exceptions –Incorrect behavior

Compile Problems Cannot find symbol:

Compile Problems Cannot find symbol: wrong parameters

Compile Problems Cannot find symbol:

Compile Problems Cannot find symbol: void constructor

Compile Problems Cannot find symbol:

Compile Problems Cannot find symbol: package not imported

Compile Problems Not abstract:

Compile Problems Not abstract: interface not implemented

Runtime Exceptions NullPointerException:

NullPointerException: variable not initialized

Runtime Exceptions in Library Code

Runtime problems: Incorrect behavior

Approaches to Debugging

bug - a defect (inappropriate behavior) in a piece of software debugging - the process of identifying the cause of a bug and repairing it it is more efficient to prevent bugs than to remove them

It is estimated that 75% of disease in the United States could be prevented by appropriate lifestyle changes (e.g, not smoking, exercising, eating appropriately, relieving stress) true or false? 75% of software defects could be prevented by appropriate software development methodologies: –analysis –design –code review –unit testing

But if you didn’t take sufficient preventive measures, or if you did but still have some bugs (the other 25%), you must debug the program how are bugs discovered? –through formal testing (good) –in use (bad) bugs can be extremely difficult to find, especially in large programs –sometimes a bug doesn’t manifest until millions of instructions later (after the code that caused the bug) –sometimes a bug manifests in a different part of the program than the part that caused it

Approaches to debugging: –debugging by flailing –debugging by experience –debugging by thinking

Heuristics (rules of thumb) for debugging*: –create a simple test case that always produces the bug (if its not repeatable, you can’t know if you’ve solved it) –describe the bug (in writing, and/or to someone else) Make a plan: –formulate some hypotheses –test the hypotheses –keep notes * adapted from Debugging by Thinking, by Charles Metzger

Techniques for debugging*: –read the source code! –describe the bug to someone else (very valuable) –print out the values of variables/objects –print out the names of methods that are executed –use more sophisticated instrumentation –use a debugger to follow the execution of the code, and to look at variables –use assertions to check assumptions * adapted from Debugging by Thinking, by Charles Metzger