70 likes | 99 Views
Dive into the world of debugging with this comprehensive guide, covering essentials like defining debugging, stepping through code, and practical exercises on PolarGrid and RectangularGrid. Explore solving runtime errors, narrowing down bug location, and more to enhance your coding skills.
E N D
Debugginng CPS004 Spring 2004 http://www.cs.duke.edu/education/courses/spring04/cps004/
The Plan • Define debugging • Overview of how to debug • Guided practice on PolarGrid.java • Independent practice on RectangularGrid.java CPS004 Spring 2004 http://www.cs.duke.edu/education/courses/spring04/cps004/
What it is Solving runtime errors Stepping through code with anticipation Narrowing down the location of the bug Recreating the bug consistently What it is not Fixing compilation errors Stepping though code blindly Debugging Defined CPS004 Spring 2004 http://www.cs.duke.edu/education/courses/spring04/cps004/
How to Debug • Be able to recreate the bug. • Identify the last place the code reaches during correct execution. • Anticipating what should happen next and step through the code. • When the unanticipated occurs, investigate why and fix the bug. CPS004 Spring 2004 http://www.cs.duke.edu/education/courses/spring04/cps004/
PolarGrid.java This class is intended to eventually be used to layout objects in concentric circles: CPS004 Spring 2004 http://www.cs.duke.edu/education/courses/spring04/cps004/
RectangularGrid.java This class is intended to eventually be used to layout objects in rows and columns CPS004 Spring 2004 http://www.cs.duke.edu/education/courses/spring04/cps004/
Guided Practice • Go to the code link from the course website. Save Buggy.jar to the Desktop • Open up Eclipse, start a new project, and import Buggy.jar. • Run PolarGrid.java • Look over the source code for PolarGrid CPS004 Spring 2004 http://www.cs.duke.edu/education/courses/spring04/cps004/