4 ms·
A variable us something that varies, mutates, changes value, call it what you will. Global mutable state (i'd say, any non-local mutable state) complicates thin
by nine_k 8y ago
A variable us something that varies, mutates, changes value, call it what you will. Global mutable state (i'd say, any non-local mutable state) complicates things and is a defect attractor.
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.
- AstralStorm 8y agoThat 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.