Debugging Strategies from Software Carpentry. Agan's Rules Many people make debugging harder than it needs to be by: Using inadequate tools Not going.

Slides:



Advertisements
Similar presentations
Test-First Programming. The tests should drive you to write the code, the reason you write code is to get a test to succeed, and you should only write.
Advertisements

Test process essentials Riitta Viitamäki,
CSE 331 SOFTWARE DESIGN & IMPLEMENTATION DEBUGGING Autumn 2011 Bug-Date: Sept 9, 1947.
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.
Software Engineering Session 14 INFM 603. Software Software represents an aspect of reality –Input and output represent the state of the world –Software.
1 Design and Integration: Part 1. 2 What’s a metaphor? Ward Cunningham cites George Lakoff’s book, Metaphors We Live By: Lakoff argues that the assumptions.
Debugging Introduction to Computing Science and Programming I.
Getting an Experimental Idea Psych 231: Research Methods in Psychology.
Debugging CPSC 315 – Programming Studio Fall 2008.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Applied Software Project Management 1 Introduction Dr. Mengxia Zhu Computer Science Department Southern Illinois University Carbondale.
2/9/2007EECS150 Lab Lecture #41 Debugging EECS150 Spring2007 – Lab Lecture #4 Laura Pelton Greg Gibeling.
1 Today More on random testing + symbolic constraint solving (“concolic” testing) Using summaries to explore fewer paths (SMART) While preserving level.
The Basic Tools Presented by: Robert E., & Jonathan Chase.
02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling.
CODING Research Data Management. Research Data Management Coding When writing software or analytical code it is important that others and your future.
1 CSc Senior Project Software Testing. 2 Preface “The amount of required study of testing techniques is trivial – a few hours over the course of.
CIT 590 Unit testing. Agenda Debugging attempt 2 (because I am stubborn) What is unit testing Why? Unit testing framework in Python.
CSE 486/586 CSE 486/586 Distributed Systems PA Best Practices Steve Ko Computer Sciences and Engineering University at Buffalo.
Software Testing. Definition To test a program is to try to make it fail.
1 A Real-World Development Lifecycle Greg Wilson
INFO 637Lecture #81 Software Engineering Process II Integration and System Testing INFO 637 Glenn Booker.
Microsoft ® Office 2007 Training Security II: Turn off the Message Bar and run code safely presents:
Painless Bug Tracking Michael Tsai 2011/9/30. Reference  html 2.
Chapter 8 – Software Testing Lecture 1 1Chapter 8 Software testing The bearing of a child takes nine months, no matter how many women are assigned. Many.
Testing in Extreme Programming
ICAPRG301A Week 4Buggy Programming ICAPRG301A Apply introductory programming techniques Program Bugs US Navy Admiral Grace Hopper is often credited with.
Discussion of Assignment 9 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas at Arlington.
Big Idea 1: The Practice of Science Description A: Scientific inquiry is a multifaceted activity; the processes of science include the formulation of scientifically.
Methods of Science Section 1.1. Methods of Science 3 areas of science: Life, Earth, Physical –What is involved in each? Scientific Explanations- not always.
1 Principles of Computer Science I Prof. Nadeem Abdul Hamid CSC 120 – Fall 2005 Lecture Unit 10 - Testing.
Debugging. Compile problems Read the whole complaint! Runtime problems –Exceptions –Incorrect behavior.
Chapter 10 – Testing and Debugging. Chapter Goals ► Learn techniques to test your code ► Learn to carry out unit tests ► Understand principles of test.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
DEBUGGING. BUG A software bug is an error, flaw, failure, or fault in a computer program or system that causes it to produce an incorrect or unexpected.
COMP 121 Week 1: Testing and Debugging. Testing Program testing can be used to show the presence of bugs, but never to show their absence! ~ Edsger Dijkstra.
Chapter 22 Developer testing Peter J. Lane. Testing can be difficult for developers to follow  Testing’s goal runs counter to the goals of the other.
Procedural Programming. Programming Process 1.Understand the problem 2.Outline a general solution 3.Decompose the general solution into manageable component.
CSE 232: C++ debugging in Visual Studio and emacs C++ Debugging (in Visual Studio and emacs) We’ve looked at programs from a text-based mode –Shell commands.
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
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.
Object Orientation Concepts, Terminology and a Story. © Allan C. Milne School of Engineering, Computing & Applied Mathematics University of Abertay v
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Week 14 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Or, “In search of the lazy programmer”.   A slide with a fancy title (and #)counts  Except this one  Ask questions at any time Rules.
Scientific Debugging. Errors in Software Errors are unexpected behaviors or outputs in programs As long as software is developed by humans, it will contain.
UHCS 2005, slide 1 About Continuous Integration. UHCS 2005, slide 2 Why do you write Unit Test ? Improve quality/robustness of your code Quick feedback.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
Debugging: Tips and Tools Also, Aloha Recitation Wednesday, February 7th, 2007.
Systems Dev. Tutorial IV: Debugging: Tips and Tools Recitation Wednesday, Sept 27th, 2006.
Machine Learning in Practice Lecture 2 Carolyn Penstein Rosé Language Technologies Institute/ Human-Computer Interaction Institute.
Journal 9/8/15 Is there anything in your life that you are 100% certain about? Anything you know for sure? Objective Tonight’s Homework To learn about.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
Science is a process, or method, that usually starts with an observation.
1 ENERGY 211 / CME 211 Lecture 14 October 22, 2008.
MEWT 2 13 th September Regression Testing: The Bane of the Tester Paul Berry (written on the train)
Software Testing and Quality Assurance Practical Considerations (1) 1.
MOOR ERROR HANDLING Types of error How to test your code for errors How to detect errors How to recover from errors.
CSC 108H: Introduction to Computer Programming
Debugging Intermittent Issues
Programmer: Roman Martushev
DEBUGGING CS2110.
CSE 303 Concepts and Tools for Software Development
Chapter 7 –Implementation Issues
EECS150 Fall 2007 – Lab Lecture #4 Shah Bawany
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Debugging EECS150 Fall Lab Lecture #4 Sarah Swisher
Debugging EECS150 Fall Lab Lecture #4 Sarah Swisher
Program Design Invasion Percolation: The Grid
Presentation transcript:

Debugging Strategies from Software Carpentry

Agan's Rules Many people make debugging harder than it needs to be by: Using inadequate tools Not going about it systematically Becoming impatient Agans' Rules [Agans 2002] describe how to apply the scientific method to debuggingAgans 2002 Observe a failure Invent a hypothesis explaining the cause Test the hypothesis by running an experiment (i.e., a test) Repeat until the bug has been found

Rule 0 The simplest bugs to fix are the ones that don't exist Design, reflect, discuss, then code “A week of hard work can sometimes save you an hour of thought.” Design and build your code with testing and debugging in mind Minimize the amount of “spooky action at a distance” Minimize the number of things programmers have to keep track of at any one time Train yourself to do things right, so that you'll code well even when you're tired, stressed, and facing a deadline “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?” (Brian Kernighan)

Rule 1: What is it Supposed to Do? First step is knowing what the problem is “It doesn't work” isn't good enough What exactly is going wrong? How do you know? You will learn a lot by following execution in a debugger and trying to anticipate what the program is going to do next Requires you to know how the software is supposed to behave Is this case covered by the specification? If not:  Do you have enough knowledge to extrapolate?  Do you have the right to do so? Try not to let what you want to see influence what you actually observe It's harder than you'd think [Hock 2004]Hock 2004

Rule 2: Is it Plugged In? Are you actually exercising the problem that you think you are? Are you giving it the right test data? Is it configured the way you think it is? Is it the version you think it is? Has the feature actually been implemented yet? Why are you sure?  Maybe the reason you can't isolate the problem is that it's not there Another argument in favor of automatic regression tests! Guaranteed to rerun the test the same way each time Also a good argument against automatic regression tests If the test is wrong, it will generate the same misleading result each time

Rule 3: Make it Fail You can only debug things when they go wrong So find a test case that makes the code fail every time Then try to find a simpler one Or start with a trivially simple test case that passes, then add complexity until it fails Each experiment becomes a test case So that you can re-run all of them with a single command How else are you going to know that the bug has actually been fixed? Use the scientific method Formulate a hypothesis, make a prediction, conduct an experiment, repeat Remember, it's computer science, not computer flip-a-coin