Cape Cod Gunny just wrote a blog article about how to replace a global variable by a static class instance.
But I had to react!
Using such static declaration is just another way of creating a global
variable.
This is just a global variable in disguise.
In fact, the generated asm will be just like a global variable!
It encapsulates the global declaration within a class name space, but it is
still IMHO a very wrong design.
I've seen so many C# or Java code which used such a pattern (there is no global
variable in those languages), and it has the same disadvantages as global
variables.
Just like the singleton
syndrome,
Code is just not re-entrant nor thread-safe.
Nightmare to debug and let evolve.