I am not sure what the best practices are here, but I often see abbreviated variable names especially when the scope is small. So (to use simple Ruby examples) instead of def add_location(name, coordinates)
, I see things like def add_loc(name, coord)
—and I might even see something like def add_loc(n, x, y)
. I imagine that longer names might tire a person out when they're accustomed to seeing abbreviations.
Does verbosity help readability, or does it just hurt everyone's eyes?—Do people prefer abbreviations and shortened names over longer names?
Personally, I would MUCH rather see longer names that actually mean something without having to determine the context first. Of course, variables that don't lend real meaning, such as counters, I still use small meaningless variable names (such as i
or x
), but otherwise verbosity is clarity most of the time. This is especially true with public APIs.
This can be taken too far, however. I've seen some VB code in the past that way ridiculous. Moderation like everything else!
Never abbr.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With