TESTING ----------- - black-box testing - no knowledge, try to break - white-box testing - try to execute every possibility in code - unit testing - separate code section to test each method - data for testing: - makeup literal values - especially boundary cases - random values - files, user input - loops to generate - regression testing - create data set for testing - upgrade program - go back and test with original set DEBUGGING ----------- - jGRASP debugging tools - jump into code at breakpoint - step through code - step into your code - watch variables - print variable values - compile often - comment out sections ERROR HANDLING ------------------ - user mistakes - invalid data - wrong data type - files not found - not enough tokens/data - null pointer - divide by 0 - out of bounds - casting/type mismatch - stack overflow - infinite loop EXCEPTIONS ----------------- - objects - many classes Throwable class - top level (extends Object) Throwable() Throwable(String msg) String getMessage() void printStackTrace() void printStackTrace(PrintWriter out) toString() to use: encounter error (invalid data): generic: (new Throwable()).printStackTrace(); specific: Throwable t= new Throwable("bad hour, must be 0-23"); System.err.println(t.getMessage()); t.printStackTrace(); Exception class - extends Throwable - parent of other exception classes RuntimeException - extends Exception ArithmeticException - extends RuntimeException - divide by 0 c IOException c FileNotFoundException IllegalArgumentException NumberFormatException (parsing primitive types) [Array/String]IndexOutOfBoundsException NullPointerException InputMismatchException (Scanner) type of exceptions: checked: compiler will recognize & require handling handling: 1) throws 2) try/catch unchecked