in reply to Re^2: Generating report on variables and alike...
in thread Generating report on variables and alike...

Except as loop indices or as part of mathematical functions such as if ($x^2 + $y^2 == $z^2) { ... }. And, useless variables are only useless outside of context. %data might be perfectly acceptable in a properly-named function.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Replies are listed 'Best First'.
Re^4: Generating report on variables and alike...
by Your Mother (Archbishop) on Apr 21, 2008 at 16:24 UTC

    I think the same kind of context heuristics used for single letter names could be extended to names like %tmp, %arg, and %data (or reaonsable single letters for cases like $c/$f/$k in a temperature sub). Check their scope. They are pretty reasonable in a small loop but I'd argue that in a main:: space or a block/sub longer than...? 10? lines, they could be named better and a critic rule might suggest that. Normally when I find myself using that kind of name it's out of haste and I wouldn't mind an automated kick in the pants to make me stop for 90 seconds to think about how it will really read to the next hacker (or to me in 6 months).