Debugging Methodology

Let’s take a quick look at some techniques involved in code debugging. Debugging can be broken into three stages:

  • Recognizing and reproducing a problem

  • Identifying the source of the problem

  • Fixing the problem

Recognizing Bugs

Very often, we recognize code problems as part of the active process of programming. That is, we write some code, test our movie, and find that the movie doesn’t work properly. Problem recognized.

The earlier a problem is discovered, the better. The process of writing code should therefore be a constant ebb and flow of writing and testing—write a few lines, export the movie, make sure the lines work as expected, then write a few more lines, export the movie, and so on. Make sure each component of a program works on its own before testing the program as a whole. Try not to get carried away writing a complex body of code without testing it frequently along the way.

Don’t assume your movie is perfect just because you can’t find any bugs on your own. Always schedule time for external testing by target users, particularly if the code you are delivering is part of a product or a service intended for a client. As described earlier, implement error checking to head off possible problems with incorrect data input. For example, if you write a function that expects an integer argument, you might use the typeof operator to verify that the input parameters are of the correct type. Also test end conditions such as extremely large, small, and negative values, ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.