Singletons considered harmful

July 4, 2007 – 2:31 pm

Alex Miller, Steve Yegge, and this poster explain.

Among the reasons given:

  • Singletons are most commonly used as excuses to have global variables and functions.
  • As Steve puts it, “using the Singleton is usually just a sign of premature optimization…” .
  • Singletons make it difficult when later you decide you actually need more than one of that type or subtypes.

Post a Comment