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, including zero.
Don't underestimate the value of finding the minimum
reproducible steps that replicate the problem. These
should be the fewest steps that recreate the error reliably. A bug
report such as, "I played it for an hour and then it
froze" is not very helpful. Useful bug reports include numbered
steps such as:
Enter 0 for the number of years.
Click the Calculate button.
The results field shows "NaN" instead of a dollar amount.