On Thu, Jul 24, 2008 at 11:22 PM, Peña, Botp [email protected]
wrote:
indeed, but as i said, i prefer short variable names. I am relaxed on object and methods names however, eg, attributes may be more descriptive …
Look out, classic appeal to authority coming up:
“Names that are too short don’t convey enough meaning. The problem
with names like X1 and X2 is that even if you can discover what X is,
you won’t know anything about the relationship between X1 and X2…
Gorla, Benander, and Benander found that the effort to debug… was
minimized when variables had names that averaged 10 to 16 characters
(1990)”
– Steve McConnel, Code Complete
“A name should be informative, concise, memorable, and pronounceable
if possible”
– Brian Kernighan and Rob Pike, The Practice of Programming
IIRC The Pragmatic Programmer by Dave T. and Andy H. contains
similar advice, but I don’t have a copy of it handy (it stays by my
desk at work).
It is worth considering that if your favored style leads to unclear
code in your favored language, it may be time to reconsider your
favored style.
Consider also that your clarifying comments may become obfuscating
comments when a global search and replace replaces the variable name
but not the comment.
–
Avdi
Home: http://avdi.org
Developer Blog: http://avdi.org/devblog/
Twitter: http://twitter.com/avdi
Journal: http://avdi.livejournal.com