5 ms·
It's funny how much I dislike the top two alternatives to globals, at least how they're typically implemented today. For me it's a case where the cure is worse
by drblast 8y ago
It's funny how much I dislike the top two alternatives to globals, at least how they're typically implemented today. For me it's a case where the cure is worse than the disease.
I've worked with a codebase where the global state was passed around as a configuration object, and that made heavy liberal use of dependency inversion. No other code base I've seen was so obtuse...it was nearly impossible to know what a line of code did but looking at it.
Dependency injection and configuration objects certainly can be useful, but the bad design they seem to encourage makes me think very carefully about using them.
- AstralStorm 8y agoIt is still global state, albeit better boxed and automatically attached to places that need it. If it is mutable, you have even more problems. About the only way to deal with this is to strictly enforce contracts and completeness when using and implementing such a thing.