in reply to The difficulties of commenting code

I've changed my style of commenting many times (as many times as I have changed my style of coding).

I have found that if I write clear code and use meaningful variable names comments are fairly unnecessary. This is not to say that I shouldn't comment the code anyway, because what is clear and meaningful to me may not be to someone else.

What I have found extremely handy is commenting the ends of my blocks and subroutines if they are more than a few lines apart. For me finding the ends makes life easier (and the ends normally don't change).

if ($some_id eq "somthing"){# beginning of some_id ... do lots of meaningful and impressive things here for my $i (0 .. 10){ do something brief here } } else { # else of some_id &a_really_descriptive_thingy; } # end of some_id .... sub a_really_descriptive_thingy { ....something fun happens here } # end of a_really_descriptive_thingy
One thing I have stopped doing is commenting my code with poetry, jokes and completely meaningless bits.

I still get my chops busted for one comment I made in the middle of a fairly routine script.

# Reset Alien Receptor Beam!

The guy spent an hour trying to find it to reset it...:)

EEjack