Forum Discussion
RokuMarkn
11 years agoVisitor
There are situations where globals are appropriate, such as global constants or (in some cases) singletons like a Registry or FontRegistry. Experienced programmers already know that globals, like gotos, are dangerous. But in this forum there are readers with a wide range of experience, so it's hard to give guidance to inexperienced programmers without saying something that an experienced programmer, looking at a wider range of possibilities, may object to. But when a programmer with no experience with globals talks about moving all their data into globals, the appropriate response is "don't do that". Similarly if a new programmer recently discovered gotos and was considering replacing all his for loops with the more "powerful" goto, I'd say "bad idea". I did say globals should be used with caution, not that they should never be used. I've probably used at least one global in every BrightScript program I've written. I would still advise new programmers to mostly avoid globals, since they don't yet have the experience to see when they're being used inappropriately.
--Mark
--Mark