How To Have Fewer Bugs Starting Today
-Conduct Creative Code Reviews.
Code reviews can be formal or informal, and they can be great even if you’re a single-person team. I’ve had great luck read code printouts in all sorts of odd situations – in the pool, at the beach. Give it a shot. Try using markers and hacking the printouts all up. Try pasting all your code on the walls of a room, and assign a section of a wall to each team member.
-Keep Your Variable Names UP TO DATE.
It’s easy to let variable usage drift slightly over time. A variable starts doing X, but changes oh-so-slightly over time, and eventually it doesn’t have anything to do with X. This is very dangerous – fact is, it’d be better to name that variable TEMP or something nondescriptive, because at least then we wouldn’t have any wrong ideas. If a variable name is off, we can end up with some very nasty bugs.
-Use lint or equivalent.
Lint is your friend, and it’s very smart. If you language supports it or an equivalent tool, use it. Lint may seem annoying at first, but all it’s warnings have reasons – if you can eliminate as many of them as possible, you’ll code will be vastly improved. (You can’t always get your code totally lint free – believe me, I’ve tried.)
Many languages that don’t support lint still have similar compiler/interpreter warnings – often, you can turn on a higher compiler warning mode. If so, turn all the warning options up to max, and pay very close attention.
-Use automated testing, and make sure it works.
If you aren’t already use automated testing, start now. Make sure that you aren’t doing it just so that you “do automated testing”, too – be sure to integrate it with your development. If you find a bug, implement a test to detect that bug – that way you can be completely confident that bug, or a similar one, doesn’t exist, even after you make significant changes.
-If it is annoying, reimplement.
It’s tempting to just ignore problem areas. Don’t. If a particular section of code, whether it be large or small, bugs you, refactor it. Fact is, the buggiest sections of code are the parts that need to be worked on the most. If you are always giving attention to the worse sections of code, it’s amazing how quickly you can get the overall quality of your project higher.
David Berube is a writer, software developer, and speaker.
Want to know five ways to sell more on your website?
Check out http://berubeconsulting.com/ for your free report.