1. 4
  1.  

  2. 5

    Oh but wait a moment, it seems like having it in a class isn’t really adding much value now.

    Well yes of course, perhaps we could move the variable outside of the class if our language supports it.

    Yes… That seems better! Oh. But hang on, isn’t that then just a global variable? I’m sure I remember something about those being problematic at times.

    No. Just be better. Didn’t you say there are no bad people on your team? Well then, why are you worrying at all? Simply write perfect code with complete discipline and you won’t have any problems.

    Fin.


    N.B. I’m not entirely sure that the date on this article is correct. It says it’s 2015, but there have been much better solutions to the singleton problem for many years. Very peculiar.

    1. 3

      A singleton holds a global static variable. The fact that it’s usually (entirely) private is its only slight slaving grace. Making it a little more public introduces issues of thread-safety and referential transparency that didn’t exist before, and wouldn’t exist at all using a saner pattern.