Syntactic Confectionery Delight | |
PerlMonks |
(jeffa) Re: Of variable {mice} and its name {man}.by jeffa (Bishop) |
on Jun 01, 2002 at 14:40 UTC ( [id://170914]=note: print w/replies, xml ) | Need Help?? |
I will agree, variable naming is very important, but it
really depends upon scope. If i am writing a one-liner,
i'll use the fewest characters possible, such as $f, @f,
or %f. If i am writing a throw away script, i don't feel
quilty for using foo, bar, baz, and qux here and there.
If it is a script that i plan for others to use, i sit
and think very carefully about the names. If i am working
with a group, i will do my best to stick to whatever
standards they have agreed upon.
Coming from Java, i used to name my variables like employeeRecord and thingWithNoName, but now i stick to the convention of using all lower case and separating words with the underscore - thing_with_no_name. This also keeps me from chosing long names since i hate reaching for the underscore key. ;) When confronted with mental block on finding a good name, if i can't think of one in 5 minutes or less, i will pick something and move on. Leaving a comment that promises to rename the variable reminds me of why i did so. I really feel that names are important, but not so important as to get stuck in rut over them. This is similar to listening to someone's conversation when they pause for far too long trying to find the right word, completely losing their train of thought. Final comment - plurals. tye finally convinced me to avoid using plurals for arrays and hashes, because they already indicate a colletion: @file, @line, %record. This keeps me from guessing between $file and @file, $record and %record. This is also a new practice for me, so i sometimes forget. jeffa Consistency is golden
In Section
Meditations
|
|