Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Akwardness or hoop-jumping to unit testAkwardness or hoop-jumping to unit test such a "singleton" is one potential downside in addition to serialization.

Contrast this with unit testing a true (i.e. instantiable) singletonunit testing a true (i.e. instantiable) singleton.

Ultimately, a singleton guarantees a single instance of a class, whereas a static class is not instantiable as @JStevenPerry points out (and I expect you already understand): the two are simply not the same although they can in many ways be employed similarly.

Akwardness or hoop-jumping to unit test such a "singleton" is one potential downside in addition to serialization.

Contrast this with unit testing a true (i.e. instantiable) singleton.

Ultimately, a singleton guarantees a single instance of a class, whereas a static class is not instantiable as @JStevenPerry points out (and I expect you already understand): the two are simply not the same although they can in many ways be employed similarly.

Akwardness or hoop-jumping to unit test such a "singleton" is one potential downside in addition to serialization.

Contrast this with unit testing a true (i.e. instantiable) singleton.

Ultimately, a singleton guarantees a single instance of a class, whereas a static class is not instantiable as @JStevenPerry points out (and I expect you already understand): the two are simply not the same although they can in many ways be employed similarly.

Source Link
J0e3gan
  • 9k
  • 10
  • 58
  • 81

Akwardness or hoop-jumping to unit test such a "singleton" is one potential downside in addition to serialization.

Contrast this with unit testing a true (i.e. instantiable) singleton.

Ultimately, a singleton guarantees a single instance of a class, whereas a static class is not instantiable as @JStevenPerry points out (and I expect you already understand): the two are simply not the same although they can in many ways be employed similarly.