Re:Global variables are bad (2013)
by AstralStorm on Thursday July 26, 2018 @04:19AM
(#17615900)
That is presuming they stay constant forever. Which generally only makes sense for mathematical constants and type bounds.
Otherwise it is better to pass them in (via dependency injection or otherwise) encapsulated so that enhancing the code for them to become variable or have versions is easy.
Global constants are fine. Something like pi is as global as it gets, and it's never a problem.
There's an intermediate case of "global config info" which is technically mutable but is only mutated during a program startup, and stays constant during execution.