This is a black art! Part of the arcane flows of programming which can be almost mystical. Some programmers seem to have a sixth sense when it comes to spotting errors. However there are some systematic ways of finding errors and ultimately fixing them.

The most common source of errors are

A good programmer would automatically look at these straight away. They would also run tests which use extreme and abnormal data. Good testing of your code is critical to ensure that it will do what it is supposed to and reduce the amount of logical errors.

In order to minimize errors you should

  1. Make sure your code is well written
  2. Look very carefully over the above points in your code
  3. Test your code using extreme and abnormal test data
  4. Test it again! Then get someone else to test it!

If you follow the above steps (read the related sections for more details) you should minimize the amount of errors in your code.