Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Danger, danger Will Robinson (documenting code)

by yakko (Friar)
on Mar 30, 2001 at 09:55 UTC ( #68286=note: print w/replies, xml ) Need Help??

in reply to Danger, danger Will Robinson (documenting code)

In the AppleII world, I got to play that "What Assembler (and OS) is it?" game... but on the whole, decent listings included this information, or it was a dead giveaway (ie, a big fat "MLI = $BF00 ;ProDOS MLI entry" is a good indicator that this program isn't for DOS 3.3...)

A recent peeve of mine has been not just what comments say, but what one names the variables. This, IMHO, is just as important as meaningful comments -- perhaps even more so. Check this out:

# handle CTCP {LOOK,OGLE} sub _lookpm { my $boo=shift(@_); my @x=split(/ /,$boo); my $y=(split('!',$x[0],2))[0]; my $z=IRC::get_info(3); my $man=IRC::get_info(1); my $booya=$x[2]; . . .
Even though this snippet is my own that I just altered extremely to provide example, when I saw very similar code in another script when I was just starting out in perl, it proved that variable names -do- matter, and -do- provide insight into the program's workings. It doesn't have to be ugly, tho:
# handle CTCP {LOOK,OGLE} sub _lookpm { my $line=shift(@_); my @pargv=split(/ /,$line); my $who=(split('!',$pargv[0],2))[0]; my $serv=IRC::get_info(3); my $nick=IRC::get_info(1); my $context=$pargv[2]; . . .
. . . and it's still debatable as to the usage of some of these vars. I'll have to work on cleaning it up. :o)

Which would you rather have the pleasure of trying to understand?

Me spell chucker work grate. Need grandma chicken.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://68286]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2017-11-25 00:54 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (355 votes). Check out past polls.