Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: coding rules

by ikegami (Patriarch)
on Jun 09, 2005 at 05:30 UTC ( [id://464966]=note: print w/replies, xml ) Need Help??


in reply to coding rules

The first issue I'd like to raise is with item #3, "Package variables in all caps". All-caps usually denotes constants. While package variables are usually constants, they are not always so. To use all-caps for something that isn't a constant will confuse your code's readers. I have yet to find a method of identifying non-constant globals with which I'm happy.

By the way, do you mean "global variables" when you say "package variables"? It's possible to have global variables that are lexicals rather than package variables.

I also have a commment about "aref_". I find the sigil+pluralization already disambiguates references from non-references. For example, consider $pearl vs $pearls vs @pearls. The first is an object, the second is an array ref, and the third is an array. True, they look rather similar. But then again, the last two are quite similar, and anyone who reads English can immediately recognize the difference between the first two without even thinking. Granted, there are time where I may wish to disambiguate a variable's content, but I find it a step backwards to require prefixes such as "aref_".

Finally, I also agree with QM's comment and Forsaken's comment to the last word.

Replies are listed 'Best First'.
Re^2: coding rules
by ihb (Deacon) on Jun 09, 2005 at 06:04 UTC

    While package variables are usually constants, they are not always so. To use all-caps for something that isn't a constant will confuse your code's readers. I have yet to find a method of identifying non-constant globals with which I'm happy.

    Capitalizing globals that may be changed, like $Stuff, is something I find nice.

    ihb

    See perltoc if you don't know which perldoc to read!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-23 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found