📝Global variables to pass rarely-used dependencies

Global variables are often used to pass rarely-used dependencies/parameters. e.g., stdin/stdout are usually global variables in languages because you never know when you want to print something.

This is exactly why global variables are useful and the source of all their problems: you don’t have to pass them explicitly to the function, but that also makes it harder to inject dependencies or test pieces.

See also


Want to receive my 🖋 posts as I publish them?