Debugging by comments

In: Software Development

Posted by Geries Handal

15 Jul 2010

You have written your code, ran it and looks ready to be committed. Once is committed it can be tested by another member of a the team. However,why no write some comments for your code before committing it, which will help you find some bugs.  By writing comments, you will have to dissect your code piece by piece, which will lead you to find common errors and makes your code understandable for other (and your future you).

Is not just about just writing one liners, write them with the following set of mind: it will be read by somebody that knows nothing about the applications or program, imagining the target reader is a new member of your team. This will help you see your code from a different perspective and go into details. By submerging in to details, you will  find bugs in your code before going into the testing stage.

There are two advantages of this method: First your code is readable and readable code is better code. Second, you save resources by saving a bug report. Testers will not test code, find bugs and return it to you. You will NOT stop your current task and go back to fix a careless bug and resubmit it for testing. Instead you will spend your time producing new code.

Comment Form

 

About this blog

A personal blog where I write about my current projects, work and interests. The posts are a reflection on my current self, varying over time, since change is the only constant.

Welcome to G To The Square, my thoughts on ICT, Business and Life... in a Square.