http://qs321.pair.com?node_id=47880


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