4 ms·
You get functions that are easily testable in isolation with all state provided in parameters. You also get explicit dependencies and scoping controlled by cal
by rafaelmn 2y ago
You get functions that are easily testable in isolation with all state provided in parameters.
You also get explicit dependencies and scoping controlled by caller.
I don't mind globals but saying you get nothing for avoiding them is :/
- Gibbon1 2y agoI tend to use getter and setter functions to access globals and manage state. Advantage only the function that depends on the global needs to bring in the dependency.
- wruza 2y agoIf that’s so useful, make your language support the concept of lexical environments instead. Otherwise it’s just manual sunsetting every day of week. Our craft is full of this “let’s pretend we’re in a lisp with good syntax” where half of it is missing, but fine, we’ll simulate it by hand. Dirt and sticks engineering. (To be clear, I’m just tangentially ranting about the state of things in general, might as well post this under somewhere else.)