Global Variables: How many is good?

I often stress a bit when I’m managing my global/local variables, and I’ve had this question:
What’s the appropriate number of global variables to declare when programming to avoid namespace pollution?

2 Likes

This StackOverflow thread is pretty interesting. Essentially, it says you should have as many as you need, without anything unnecessary; if you can have something locally scoped, do, but don’t worry about having global variables, as long as they’re necessary.

2 Likes

This helps a lot! Thanks!

2 Likes

thnaks . help me too