Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Debugging. Compile problems Read the whole complaint! Runtime problems –Exceptions –Incorrect behavior."— Presentation transcript:

1 Debugging

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

3 Compile Problems Cannot find symbol:

4 Compile Problems Cannot find symbol: wrong parameters

5 Compile Problems Cannot find symbol:

6 Compile Problems Cannot find symbol: void constructor

7 Compile Problems Cannot find symbol:

8 Compile Problems Cannot find symbol: package not imported

9 Compile Problems Not abstract:

10 Compile Problems Not abstract: interface not implemented

11 Runtime Exceptions NullPointerException:

12 NullPointerException: variable not initialized

13 Runtime Exceptions in Library Code

14 Runtime problems: Incorrect behavior

15 Approaches to Debugging

16 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

17 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

18 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

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

20 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

21 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


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

Similar presentations


Ads by Google