Debugging. Design Well A careful design limits the necessary debugging - think “top-down” Write comments as you go, especially invariants –You can test.

Slides:



Advertisements
Similar presentations
Intro to USACO Strategy
Advertisements

1 CSC 421: Algorithm Design & Analysis Spring 2013 See online syllabus: (also on BlueLine2) Course.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 12: Stacks and Queues.
CS 206 Introduction to Computer Science II 03 / 06 / 2009 Instructor: Michael Eckmann.
Cache Table. ARP Modules Output Module Sleep until IP packet is received from IP Software Check cache table for entry corresponding to the destination.
CS 206 Introduction to Computer Science II 10 / 28 / 2009 Instructor: Michael Eckmann.
C++ Crash Course Class 1 What is programming?. What’s this course about? Goal: Be able to design, write and run simple programs in C++ on a UNIX machine.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Review C++ exception handling mechanism Try-throw-catch block How does it work What is exception specification? What if a exception is not caught?
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
1 CSC 222: Computer Programming II Spring 2004 See online syllabus at: Course goals:
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
CSE 501N Fall ‘09 11: Data Structures: Stacks, Queues, and Maps Nick Leidenfrost October 6, 2009.
1 CSC 427: Data Structures and Algorithm Analysis Fall 2006 See online syllabus (also available through Blackboard): Course goals:
C++ crash course Class 9 flight times program, using gdb.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
Data Structures for Midterm 2. C++ Data Structure Runtimes.
Lecture 2 Basic Data Structures and Recursion Review.
Data-structure-palooza Checkout DataStructures from SVN.
Final Exam Review CS Total Points – 20 Points Writing Programs – 65 Points Tracing Algorithms, determining results, and drawing pictures – 50.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
Exam 2 Review CS 3358 Data Structures. 90 Total Points – 50 Points Writing Programs – 25 Points Tracing Algorithms, determining results, and drawing pictures.
CSCI 161 Lecture 3 Martin van Bommel. Operating System Program that acts as interface to other software and the underlying hardware Operating System Utilities.
Defensive Programming. Good programming practices that protect you from your own programming mistakes, as well as those of others – Assertions – Parameter.
Today… Modularity, or Writing Functions. Winter 2016CISC101 - Prof. McLeod1.
Data Structures - Review [CLRS] – Chap 10, Chap 11, Chap 6.5.
Final Exam Review CS 3358.
CSC 421: Algorithm Design & Analysis
Using the Java Collection Libraries COMP 103 # T2
CSC 427: Data Structures and Algorithm Analysis
CSC 222: Object-Oriented Programming
Sort & Search Algorithms
CSC 222: Object-Oriented Programming
CSC 222: Computer Programming II
Generics, Exceptions and Undo Command
MIS 215 Module 1 – Unordered Lists
Chapter 15 Lists Objectives
March 29 – Testing and Priority QUeues
CSC 421: Algorithm Design & Analysis
CSC 222: Object-Oriented Programming
Statement atoms The 'atomic' components of a statement are: delimiters (indents, semicolons, etc.); keywords (built into the language); identifiers (names.
CSC 421: Algorithm Design & Analysis
COMP 2710 Software Construction Introduction to GDB
structures and their relationships." - Linus Torvalds
Principles of Computing – UFCFA3-30-1
Exam 2 Review CS 3358 Data Structures.
Some Basics for Problem Analysis and Solutions
CS 2308 Final Exam Review.
structures and their relationships." - Linus Torvalds
Exam 2 Review CS 3358 Data Structures.
Some Basics for Problem Analysis
Chapter 11 Introduction to Programming in C
Introduction to Data Structures
Exam 2 Review CS 3358 Data Structures.
Coding Concepts (Standards and Testing)
Container classes, ADTs
Visit for more Learning Resources
Road Map CS Concepts Data Structures Java Language Java Collections
Fundamental Programming
EE 312 Final Exam Review.
Information.
Chapter 3 Debugging Section 3.4
structures and their relationships." - Linus Torvalds
SPL – PS1 Introduction to C++.
Testing Slides adopted from John Jannotti, Brown University
CMPT 225 Lecture 8 – Queue.
Implementation Plan system integration required for each iteration
Presentation transcript:

Debugging

Design Well A careful design limits the necessary debugging - think “top-down” Write comments as you go, especially invariants –You can test the invariants in your code

Test Early and Often Have test cases ready as part of your design Write code in pieces, and test each independently –Usually software engineering “modules” –Also useful “in the small” Write & test I/O before algorithm, eg.

Test Cases Examples from the problem, but also… Boundary conditions Unusual inputs (but legal ones) Random test cases (if you can tell if the program was right) Small known cases, then large random ones Exhaustive, if possible (auto-generate!)

Two Kinds of Debugging Online - using IDE Offline - using output

Online Debugging Set break points Trace functions Step (“into” vs. “over”) Examine the call-stack Check values of variables Some environments save information after a crash

Offline Debugging Copious print statements Give variable name, value and location Comment out when “done” –Too much output hurts –But you might need those statements later

“Scaffolding Code” Print statements for debugging Functions to nicely print internal data structures Test case generators

Miscellaneous Don’t mix line and token I/O –In C++, this means use getline or cin<<, not both Make arrays bigger than they need to be or use self-expanding data structures Use string and other library classes when possible Java must be Main.class, no public classes

Collection Data Structures Stack (push, pop - last in first out) Queue (enqueue, dequeue - first in first out) Hash table or “map” - use, but don’t create List (linked), Vector (array-based)