Remember the conservative programming method: 1) establish a stable state, 2) write code, 3) test your code, 4) diagnose and fix errors until a new stable state is established.
A bad habit is to stop programming when your program is in an unstable state.
When diagnosing an error, isolate the location of the error by throwing extra output statements. You can't have too many.
If a function doesn't return what you expect, toss in output statements to track the value it's returning. Get used to doing this as opposed to relying on any debug tools that may be present.
What seperates computer programmers from script writers is the concern about memory usage and efficiency.
Sanitize anything that comes from the user. If the user is allowed to cause your program to commit an error, that is your error.
Test the parameters of a function for nonsense values before the function starts its work.
An error is just a result.
Always compile for one of two reasons: 1) to make it work, 2) to get more information about why it didn't work last time.
Pseudocode is what whiteboards were invented for.
Whenever an array cell is accessed according to the contents of a variable, eliminate the possibility of an out of bounds error.
While loops and recursive functions: ensure each pass brings you closer to the base condition.
Anything you do more than once is a candidate for a new function.
Sometimes whitespace can be just as useful for organizing your code as comments.
Develop or choose a variable naming convention and stick to it.
Functions that accomplish related tasks should have similar names.
Each cell of a database should not hold more than one piece of data.
Any time a project involves a database, data structures should be designed first.
The act of typing comments to explain your strategy helps you organize your thoughts as well as anyone else who may happen to read your code.