re: Are global variables bad? VIEW POST


Blanket statements are bad, because there is always a situation where they don't apply. You have to know when it is OK to make the exception though.
I tell my junior developers to start with the blanket statements: no globals, no gotos, no extern, etc. When they have some experience under their belt they'll know when it's OK to bend the rules they learned.


Maybe such simple blanket statements are okay for people just learning programmingm, but I'd expect my junior programmers to know at least some of the depth behind it.

Indeed, I'm tempted to make this an interview question. Are global variables bad? If a junior programmer can't give a sensible answer, either way, or neutral, and explain the reasons I honestly think they are underqualified.

code of conduct - report abuse