On Monday 12 January 2009 20:18:39 [email protected] wrote:
> A quick set of three basic guidelines for comments. I find these get
> my through most situations.
>
> 1. The code says what you are doing, the comments say WHY you are doing it.
>
> 2. The code is there to teach people who aren't you (which includes
> you-in-12-months) about the code, so in general they should be before
> a block of code, and introduce it.
>
> 3. Comments are for humans. Don't leave commented out old code around,
> they just mess up the comments, and you should be using version
> control for that anyway.

These are the utterly most important points, and are so very often ignored.
Read them 3 or 4 times and never waver.

You write the code
After 3 months you are amazed at how badly you commented it
After 12 months it looks like someone else's code

James
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to