Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: The difficulties of commenting code

by eejack (Hermit)
on Jun 29, 2001 at 07:32 UTC ( [id://92526]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://92526]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-03-28 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found