I prefer to use constants for configuration options instead of variables, for three reasons:
- They are global, so there's no need to inject them into functions as parameters or using a
global
keyword,
- They can't be changed by the app itself (which can happen by accident if you are not careful and cause some awkward bugs),
- Good editors offer code completion and can navigate to the line where constant was declared. This makes work with large projects that have a lot of options a bit easier. This applies to global variables as well, but constants are a bit "cleaner" (rule of thumb is to keep the global scope as clean as possible).
Example:
Index: