Debugging Is Your Friend
I truly believe that one of the most important skills of being a computer programmer is the ability to debug code. Usually when I’m writing a piece of Java code I will have dozens of lines of output testing variables for various conditions. This helps me to understand just how my code is working. What I normally do is that if I notice a piece of code isn’t working I will test the state of the variable in at least 3 places including:
- Before the code being tested
- During the code being tested
- After the code being tested
I really find that the more output messages I print the easier it is for me to trace my code and fix bugs and make enhancements.
Another thing I tend to do is to think of any extreme conditions that can occur that would interrupt the normal flow of the application and handle the error before it causes serious problems in the application. For example if I were writing a piece of code handled a valid range of values entered into an input box I would want to state an error message if a value was outside the range.
Friday, May 2nd, 2008