BlueJ Debugger Lab

When trying to debug programs, new programmers often rely on using print statements to help them find bugs in their code. Although using print statements can be helpful, it is not always the most efficient and helpful way to find errors in your program. A handy tool that most modern IDE’s have is a debugger, which will allow programmers to step through their code and see exactly what is going on.

Using a debugger is a tedious way to repair a broken program and usually a code inspection and a code trace are more effective tools. But in some cases, when all else fails, the debugger can reveal what's happening in your program at a very detailed level.

Purpose:

The purpose of this lab is gain experience with the BlueJ Debugger tool, and to become comfortable with it so it can be used in future labs and projects. When you finish this lab you should be able to:

Activities:

1. Download the debugdemo Bluej Project zip file. Open the BlueJ DebuggerTutorial.pdf. As you read the tutorial you will follow the directions for using the debugger on the debugdemo project. When you finish the tutorial, proceed to the next activity.

2. Open the debugdemo project. Click "Run Tests" and observe that the unit tests for the StringsAndSuch class are failing.

There are a few defects remaining in the logic of reverseChecker() method in the StringsAndSuch class. Use the debugger to isolate the defects and determine their cause. Then correct the code in the reverseChecker() method so that the tests will pass. DO NOT modify the test cases, only the code in the reverseChecker() method.

You should start by setting a breakpoint in the reverseChecker() method, and starting the unit tests. When the debugger window appears, step through the code and observe the values of the variables. You should be able to notice when the values become incorrect and thus isolate the cause of the defect.

Write up a description of the defects you discovered and how you corrected them.