Is it kEatSpeed or kSpeedEat?
Posted
by bobobobo
on Stack Overflow
See other posts from Stack Overflow
or by bobobobo
Published on 2010-05-07T22:03:51Z
Indexed on
2010/05/07
22:08 UTC
Read the original article
Hit count: 220
I have a bunch of related constants that are not identical. What's the better way to name them?
way #1
kWalkSpeed kRunSpeed kEatSpeed kDrinkSpeed
Or,
way #2
kSpeedWalk kSpeedRun kSpeedEat kSpeedDrink
If we evaluate these based on
- readability
- understandability
- not bug prone with subtle errors due to using wrong variable name
I think way #1 wins readability, they tie for understandability, and way #2 wins for not bug prone.
I'm not sure how often it happens to others, but when variable names like this get long, then its easy to write kSpeedEatingWhenInAHurry
when you really meant kSpeedEatingWhenInHome
, especially when using autocomplete.
Any perspectives?
© Stack Overflow or respective owner