Debugging: other issues


My program compiles and runs ok, but doesn't give me the result I expect.

These are the trickiest errors, and the reason software development houses spend hundreds of thousands of dollars employing people to run through their software and games in all the possible permutations. The solutions to these problems mainly centre on coding practice that attempts to minimise them happening in the first place.

1) First, make sure your main code has a solid algorithm. Write the algorithm into your code as comments, and convert it a line at a time.

2) Every time you write a line of code, or a couple of lines, think "how can I check this is working correctly?". If there is any chance it isn't, check the code results with a simple System.out.println.

3) If necessary, cut out all the code doing complex jobs, and paste it into a temporary text file, then rebuild the code a chunk at a time until you can see where it is going wrong.

4) When you start to use an Integrated Development Environment, spend some time leaning about its debugging and watch capabilities (search for these in the environment's help files).

5) Consider using formal Unit Testing.

6) Conduct software tests, usability tests, and stress tests, as well as spending some time refactoring your code to make it easier to maintain. Remember to regression test software that is altered.