Write code that you can trust
It will save time when it comes to debugging. Your attitude should be, the problem must be someplace else because I wrote perfect code.
Date : 2008-10-21
It might sound a little over confident but if you write bullet proof code, and then trust it, you will be able to track down problem quicker. If you write all the code, and it's all bullet proof, there wont be anything that needs tracked down.
This really covers two issues that many programmers fall prey to.
The first is unfortunate but is a fact of life. Not all programmers write great code. There are a variety of "reasons" for that, but NO excuses. There is nothing worse than having a bug in a program and tracking it down to shoddy code that you knew you should have written better. One of the most common instances of this is writing functions, or class members that don't double check their parameters before processing. We skip this step sometimes because we're sure those values will be checked before they are sent, but someday that code will change and will break down the line someplace.
The second reason for this is simply not having confidence in your code. Sometimes we do write good code but we're not positive that we did, so we spend all day searching through our code for the issue only to find it someplace else. If we had trusted our code then we would have saved ourselves a lot of time.
The only thing worse is being positive that the error is someplace else only to eventually find it in our code. The solution to this? Always write bullet proof code.
No comments yet