3 ms·
Just typical zealotry. So instead of globals we should use DependencyInjection, and now the app is magically better? For many projects it hardly matters, and I'
by tabs_masterrace 8y ago
Just typical zealotry. So instead of globals we should use DependencyInjection, and now the app is magically better? For many projects it hardly matters, and I'm not going to over complicate things when there's no practical reason for it.
- drblast 8y agoAlso modern IDEs change the game a bit. Used to be you wouldn't use globals because it was difficult to figure out what code accessed or changed their values. Now that's a right click away.
- V-2 8y agoIDE will show you where it's accessed, but it's of little use if there are two hundred fifty usages, and IDE won't fix the design choices that followed from the use of globals.
- beobab 8y agoI am still on the fence about them. Yes, they cause problems (looking at you, powershell!). Yes, they can be used as a band-aid for thorny issues (Time constraints!). They are a tool, like any other programming construct. Is making them properties and sticking them in a "GlobalVariablesByAnotherName" singleton and chucking that around better? Possibly. Possibly not. I have found, however, that any code where someone has used global variables is hard to share with other developers. Maybe that's the crux of the matter.