in reply to Long identifiers are fine (Re^2: CGI Tables)
in thread CGI Tables

Think of variable names in a LZW compression style. The more you use it, the shorter it can get, but to a point. I was just saying that for things you use capital-A All The Time, you can get by with a single letter. For me, $r is Always the same thing. It's sacred.

If you want, you can call it $apr, or whatever, but things like $apache_request are kind of like naming your dog The Happy Canine Who Is My Life-Long Friend Named Spot. When you're talking about $dbh or $cgi, you should have an idea what you're dealing with.

What I don't like is functions like this:
sub mulch { my ($x, $z, $zz, $a) = @_; $x->foo($z, $zz, $a->id()); $z->insert($x); $a->restore(); return $x; }
Isn't that informative? Without backtracing through caller after caller, you have no idea what type the variables are. Sure, you could put in some diagnostic code, but isn't that kind of absurd?

All I'm saying is that if you use someting A Lot, you can reduce the letter count accordingly. If you use it almost never, you should be pretty clear as to what it is.

Replies are listed 'Best First'.
Re^2: Long identifiers are fine (Re^2: CGI Tables)
by Flexx (Pilgrim) on Sep 02, 2002 at 15:18 UTC

    Sure, you're right, $dbh, $sth (and $foo and $bar ;) and the like are almost reserved words... ;)

    The sorry thing is, there's a lot of mulch() out there...

    However in a script where I use HTTP::Request, CGI, and XML::Parser I'd still rather have $parser, $query and $request instead of $p, $q and $r.

    But maybe that's just because qbpd are just mirrors and rotations of each other... ;)

    Cheers,
    Flexx