DEV Community

Discussion on: Are global variables bad?

Collapse
 
galdin profile image
Galdin Raphael • Edited

I look at global variables as variables in a scope you cannot reinitialize. In C it'd be C's global scope (you'll need a new application instance to reinitialize its global variables). In C# it's going to be the scope of a static class (you'll need a new application instance here again). Wikipedia has a better definition than mine 😅

Also, I think it's important to use the term global-variable in the context of the language when discussing its pros and cons.

Anyway according to your post, Application level lifetime would be my definition of global variables.

Something you might be interested in: softwareengineering.stackexchange....