What helps most in debugging a program is to have a program that let itself be debugged easily. This means that your program should be written in such a way that errors are easy to locate. This document is not about designing a program, so I will not describe ways to integrate debugging possibilities into your design, but during design, you should now and then ask yourself the question if the resulting program is easy to debug.