Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re (tilly) 1: Favorite Descriptive Variable Name

by tilly (Archbishop)
on Dec 21, 2000 at 23:52 UTC ( [id://47880]=note: print w/replies, xml ) Need Help??

in reply to Favorite Descriptive Variable Name

To go with all of these temporary variable names, here is a useful naming convention.

Make all of your flags be questions starting with "is".

One of the most common errors people make is to reverse what a flag is supposed to stand for. For instance if you are looking at a variable called $status_flag, is 1 success or failure? Who knows? Much better to call it $is_ok or $is_bad as appropriate, then there is no room for confusion.

The rule is, Say what you mean, mean what you say, and stop saying it before you mess up! Make your variables say your story. Don't leave landmines by changing what they mean. Don't make people have to maintain stuff in both comments and code. So on and so forth...

  • Comment on Re (tilly) 1: Favorite Descriptive Variable Name

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-21 20:05 GMT
Find Nodes?
    Voting Booth?

    No recent polls found