Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global Variables Bad

Tags:

c#

Ok after reading this article and also some of the examples I am still not clear on what global variables mean. So its say private variables in your class are global?

http://www.c2.com/cgi/wiki?GlobalVariablesAreBad

So can someone explain this to me in simple terms the context. Does this mean even private fields at the top of your class? I'm not clear on the definition of a "global variable" so that I can distinguish if I'm doing something "bad" in my classes.

like image 353
PositiveGuy Avatar asked Jul 22 '09 03:07

PositiveGuy


1 Answers

In C# an example of a global variable would be a public static variable on a public class. The entire program could read/write to it and it would be shared across threads as well.

like image 85
thelsdj Avatar answered Sep 23 '22 08:09

thelsdj