-3

My professor wants a "non-trivial" answer to the question of "What are the uses of a static class variable, besides constants?"

Aside from constants, the only one I can think of is keeping a count of the objects that have been instantiated from the class.

1 Answers1

0

A certainly non-trivial answer to this question can be found in this question

In short, they're used to keep global state for the class and make our lives as developers worse for fighting hard to reason about tests.

Community
  • 1
  • 1
JChrist
  • 1,734
  • 17
  • 23
  • Now that we have dependency injection, I consider singletons to be evil, as well. – azurefrog Jan 31 '17 at 22:38
  • In the era of `microservices` hype and increasing need (and demand) for horizontal scalability, singletons are coming to my mind as `code smell`, since they (usually) affect ability to scale – JChrist Feb 01 '17 at 11:52