I read in various places that the presence of variables with a global scope, i.e. an open static class with static members is considered contrary to the philosophy of OO and is not a good design. (For example, I saw comments line by line: “If you use the global, you are not doing it right.” Or words about it.)
But, if you use the settings engine provided by Visual Studio, for example. "Settings.Default.MySetting", etc., It is available worldwide throughout the application, since it is different from using an open static class?
In addition, the same results can be achieved using a singleton object, but this also provokes at least different opinions.
Global variables are just useful, (VB Module, anyone?), But I'm trying to teach myself how to execute this OO malarky correctly, so if global variables smell bad from an OO point of view, what is the alternative?
I am particularly interested in people's opinions about using the "Settings" functionality. Is this a good OO design?
Thanks for any comments.
c # global-variables settings winforms
Andy
source share