Is it kEatSpeed or kSpeedEat?
- by bobobobo
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?