Debugging, bug finding and bug avoidance Part 2 Alan Dix www.hcibook.com/alan/teaching/debugging/

Slides:



Advertisements
Similar presentations
EasyGUI “Probably the Easiest GUI in the world”. Assumptions (Teachers’ Notes) This resources sets out an introduction to using easyGUI and Python
Advertisements

 Specifies a set of methods (i.e., method headings) that any class that implements that interface must have.  An interface is a type (but is not a class).
1 Software Engineering Lecture 11 Software Testing.
FIT FIT1002 Computer Programming Unit 19 Testing and Debugging.
Programming in Visual Basic
API Design CPSC 315 – Programming Studio Fall 2008 Follows Kernighan and Pike, The Practice of Programming and Joshua Bloch’s Library-Centric Software.
Computer Science 1620 Loops.
Nov 10, Fall 2006IAT 8001 Debugging. Nov 10, Fall 2006IAT 8002 How do I know my program is broken?  Compiler Errors –easy to fix!  Runtime Exceptions.
1 CS 105 Lecture 8 Strings; Input Failure Mon, Mar 7, 2011, 3:39 pm.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Testing HCI Usability Testing. Chronological order of testing Individual program units are built and tested (white-box testing / unit testing) Units are.
Lecturer: Dr. AJ Bieszczad Chapter 76-1 Software engineering standards Standards for you Standards for others Matching design with implementation.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Jun 16, 2014IAT 2651 Debugging. Dialectical Materialism  Dialectical materialism is a strand of Marxism, synthesizing Hegel's dialectics, which proposes.
Introduction to Python
Java: Chapter 1 Computer Systems Computer Programming II.
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.
Munster Programming Training
Testing Michael Ernst CSE 140 University of Washington.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
School of Computer Science & Information Technology G6DICP - Lecture 9 Software Development Techniques.
How to Design Error Steady Code Ivaylo Bratoev Telerik Corporation
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.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)
Oct 15, 2007Sprenkle - CS1111 Objectives Creating your own functions.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
CSE 201 – Elementary Computer Programming 1 Extra Exercises Source: Suggested but not selected midterm questions.
Java Programming: From Problem Analysis to Program Design, 5e Chapter 2 Basic Elements of Java.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Debugging, bug finding and bug avoidance Part 3 Alan Dix
CSC 212 – Data Structures Prof. Matthew Hertz WTC 207D /
I Power Higher Computing Software Development Development Languages and Environments.
1 Review. 2 Creating a Runnable Program  What is the function of the compiler?  What is the function of the linker?  Java doesn't have a linker. If.
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
Design - programming Cmpe 450 Fall Dynamic Analysis Software quality Design carefully from the start Simple and clean Fewer errors Finding errors.
Test 2 Review. General Info. All tests are comprehensive. You are still responsible for the material covered prior to the first exam. You will be tested.
Exceptions Chapter 16 This chapter explains: What as exception is Why they are useful Java exception facilities.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
“Great leaders are never satisfied with current levels of performance. They are restlessly driven by possibilities and potential achievements.” – Donna.
Connecting to MySQL using Java By:. – Required to use Java.sql so that we can use Connection and Queries using strings. – Javax.swing.* needed for components.
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.
Debugging, bug finding and bug avoidance Part 1 Alan Dix
FOR LOOPS "LOOP FOR A SET NUMBER OF TIMES.". FOR ( START_VALUE; END_VALUE; INCREMENT_NUMBER ) { //YOUR_CODE_HERE } So after the word "for" (in lowercase)
Defensive Programming. Good programming practices that protect you from your own programming mistakes, as well as those of others – Assertions – Parameter.
Chapter 3 Implementing Classes
IST 210: PHP Basics IST 210: Organization of Data IST2101.
1 Building a program in C: Preprocessor, Compilation and Linkage.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Coupling and Cohesion Rajni Bhalla.
Testing Tutorial 7.
Testing and Debugging.
Testing UW CSE 160 Winter 2017.
CSE 143 Error Handling [Section 2.8] 3/30/98 CSE 143.
OUTPUT STATEMENTS GC 201.
Design by Contract Fall 2016 Version.
Some Basics for Problem Analysis and Solutions
Testing UW CSE 160 Winter 2016.
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.
Automation of Testing in the Distributed Common Ground System (Army)
Automation of Testing in the Distributed Common Ground System (Army)
Bugs & Debugging - Testing
C Programming Getting started Variables Basic C operators Conditionals
debugging, bug finding and bug avoidance Part 4
Defensive Programming
Presentation transcript:

debugging, bug finding and bug avoidance Part 2 Alan Dix

outline part 1 – general issues and heuristics part 2 – the system as it is understand and document part 3 – locating and fixing bugs part 4 – bug engineering design to expose, avoid and recover including fail-fast programming

debugging – part 2 the system as it is understand your system make assumptions explicit document interactions

understand your system collaborative walkthrough personal walkthrough –what do you think it does? print statements –what it really does! make assumptions explicit make interactions explicit

understand your system when in doubt document s = s.substring(idx+1); // +1 to skip current char bracket d = b3<<24 + b2<<16 + b1<<8 + b0; d = (b3<<24) + (b2<<16) + (b1<<8) + b0;

understand your system bugs are where you’d expect what was difficult to code? look there! where would you expect errors? look there!

understand your system bugs are where you’d expect some years ago... testing third party floating point library  try simple case 1+2=3 – OK  try cases to force 16 bit carry – FAIL soon after - problem with Microsoft C –32 bit integer subtract –carry error  answer is out 

understand your system beginnings and endings starting up –loading data (files exist, in right format?) –initialisation (doing it, doing it right, in the right order) ending –saving data –releasing resources –closing/flushing files

make assumptions explicit bad - implicit assumption int len(String str) { return str.length(); }  fails if str is null

make assumptions explicit better - documented /** str - must not be null */ int len(String str) { return str.length(); }

make assumptions explicit defensive - recover /** str - must not be null */ int len(String str) { if ( str == null ) return 0; return str.length(); }

make assumptions explicit diagnostic - log /** str - must not be null */ int len(String str) { if ( str == null ) { log(“len: str is null”); return 0; } return str.length(); }

document interactions external interactions (real world effects!) mouse events, robot controls sequence information order of events, method calls shared data static variables, references to objects hidden effects influence on other objects / components

document interactions external interactions say what causes events e.g. a component receives a MOUSE_PRESS event when and only when the user presses down a mouse button over it –N.B. not true of all Java AWT toolkits! say what happens in the real world e.g. the move(x,y) method sends a signal to the robot arm control motor moving it x cm in the X direction and y cm in the Y direction

document interactions sequence information define events order explicitly e.g. MOUSE_PRESS and MOUSE_RELEASE events always alternate in the event sequence for any mouse button –N.B. not true of all Java AWT toolkits! explain restrictions on method calls e.g. always call the xinit() method before other methods and call the close() method last –but check inside your code

document interactions shared data  hidden effects can be difficult to describe e.g. if you create a TCP/IP socket in Java, what happens to the output part if you close the input? answer: it gets closed too object Aobject B object C reference

document interactions scenarios typical paths through system –a ‘story’ about the system –what happens which objects involved how they affect data –several levels of detail e.g. see aQtive documentation at: