in reply to lazy creation of a hash
As an aside, you can start with an undefined variable and start referencing a bunch of keys (as though a nested set of “hashes containing hashrefs” with these particular keys already existed, and, miraculously, one will appear.
When you say “a public variable,” however, I immediately think that you should strictly be using a class for this. You don’t want code that is dependent upon the arrangement and use of this variable to be scattered willy-and-yob across the system: you want it to be in one place, and with a clearly defined abstract interface. These methods specify what the rest of the application wants to do (or wants to know), and (only...) this one package implements how it is done.
“Efficiency?” Schmefficiency! Once you pass a billion clock-cycles per second, no one can hear you scream. If you need a few more gigabytes, grab ’em at the grocery checkout stand ... Maintainability trumps all.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: lazy creation of a hash
by John M. Dlugosz (Monsignor) on May 13, 2011 at 01:15 UTC |