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
- organization in member list (autocomplete)
- not bug prone with subtle errors due to using wrong variable name
I think way #1 wins readability, they tie for understandability, way #2 wins for organization in autocomplete list, and way #1 also 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?