Comment your Code with Logic and Humour

Commenting your code is great for a number of reasons and ultimately it will keep your project maintainable and will save you time in the long run.

However, commenting for the sake of it or explaining every last detail is unnecesary and could actually make your code harder to work with and less maintainable.

Consider the following pointers:

Don’t comment for the sake of it.
If your code is readable and is doing nothing you wouldn’t come across ten times a day, don’t waste your time in writing it and somebody elses time in reading it.

Make it readable.
Avoid abbreviations and shortcuts in your comments that only you will know. The general rule here is write the comments for someone else, not for yourself

Update your comments.
If your modifying the code, make sure the comments represent the new logic. If you don’t have time to update the comments, as a last resort delete the existing ones - at least you won’t send people down the wrong path.

Keep it short and sweet.
Don’t write an essay and keep to the point. Long comments won’t get read and will be a waste of time for you.

Give your contact details.
Particularly relevant to web development, keep an email address in their somewhere (i.e. the top of each file) so any future developer can get your help. If you do a good job this can also get your work and recognition.

Inject a bit of humour.
We aren’t robots, add a bit of personality and it may just make the task of updating that little bit easier for you or someone else.

Are you a Developer, Designer or Copy Writer? Or Looking For One?

Click here to see 100s of jobs updated every day that you can complete to earn good money. Also find that programmer, designer or copy writer you have been looking for - advertise and get the best guy for your job - click here to find out more

2 Comments so far

  1. vask on February 23rd, 2007

    Comments should be a part of programming, for me it is important as any other part.

  2. perez_opal on February 23rd, 2007

    Sometimes you just don’t have the time and if you know for a fact the comments will not be used, I think it is more pragmatic to just forget them.

Leave a Reply

Make $100,000/Month - Every Month!

It Works! We Make Our Customers Millionaires! Act now and get $600 bonus and a Free Money Making Website! - click to get started