next up previous
Next: Week 9 Up: Program Correctness Previous: Testing:If I Write It

Scholasticus Habilus: Tool-Using Student

What tools exist to help us verify that our program is correct, or to correct it if it is incorrect?

One of the most important tools, and one that you have probably been using (but perhaps not taking full advantage of) is the IDE. (CodeWarrior, for example). IDE stands for Integrated Development Environment, and one of the things that is usually integerated into the environemtn is a debugger. Recall that a bug is an error in the code, and therefore a debugger is a tool to help you get rid of the errors in your code. Although a debugger probably isn't necessary for much of the code that you'll write in this course, it's a powerful tool, and I would think that from 2nd year onward, you should be able to use all the features of a debugger.

I'll just mention a few of the important features of the debugger; this won't be tested, but it may prove useful for those of you who wish to learn about this powerful tool.

First of all, a debugger usually gives you the ability to execute one line of your program at a time. This feature is usually called stepping through your program. By itself, this isn't a particularly great feature, but together with the ability to watch the values of variables, this becomes an extremely powerful feature. Watching values of variables allows you to observe what the values of variables are at all times during the execution of the program. A common scenario is therefore to step through lines of your code one statement at a time while observing how values of variables are changing. This gives you the ability to determine whether some lines of code are incorrectly changing values, and then to modify those lines.

There are a number of other features of a debugger and if you're interested, try playing with them and reading the appropriate documentation for the debugging environment in which you're working.

If you don't have access to a debugger, you may want to use println statements at various points in your program to print out the values of variables in order to check to see if the values are what they are supposed to be. You also may want to write a toString() method for each class so that you can easily print out the relevant values in a variable when needed.

As mentioned in the last section, including main methods in each class is possible in order to test the methods of the class.

Finally, there are some tools from the authors of our text (look under Local Libraries) which allow you to check that certain values are what you expect them to be. If they are not what is expected (as determined by a boolean expression that you provide, then an exception is generated and the program will stop and print some information about the location of the error.


next up previous
Next: Week 9 Up: Program Correctness Previous: Testing:If I Write It
Chris Trendall
Copyright ©Chris Trendall, 2001. All rights reserved.

2001-12-09