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.

Adam K

2009/1/12 Sebastian <sebastian.spi...@gmail.com>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all,
>
> recently I've started getting into Python and Django programming as
> well as shell scripting.
>
> I was wondering is there any rule or guide on good practice on how to
> comment code?
>
> For me and my current knowledge state, very low I would say :-), I do
> a lot of commenting. sometimes more than one line comments on one line
> code.
> Now I was wondering if I should place the comments before the actual
> code line, after or at the end.
>
> I like commenting in line after the code as it makes the code more
> easy to read - for me...
> But I like commenting lines preceding the code line as it keeps the
> lines itself short...
>
> I think that most would say it comes down to personal preference but I
> was wondering at the same time if there are some rules I should get
> used to right from the start.
>
>
> Cheers,
>
> seb
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (MingW32)
> Comment: http://getfiregpg.org
>
> iD8DBQFJaowNMuBzgG5z7F8RAqZoAJ9Pzw3SRaes6LOdlU4bOqCQSZPFVACghmIG
> NhFonZutl3aBKUneNvtlDOE=
> =fJ7n
> -----END PGP SIGNATURE-----
> --
> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
>
-- 
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