- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
Consts are good for just giving descriptive variable names to avoid the magic number problems, but they cause a similarly annoying problem of not being able to identify the value actually being used when the const is defined away from it's use.
My suggestion, in all languages: define consts in as close a scope as possible to their actual usage. If used in only one class; only put in that class. Multiple classes would mean make sure it's at least in the same namespace as all classes using it.
Configuration files have the advantage of being centralized, yet the name of the property in the function scope (when you retrieve it) allows you to maintain readability.