The Singleton Pattern - Anti-Pattern or Solution?

Klaus Iglberger

60 minute session
20:00-21:00, Thursday, 14th July 2022

Singleton is indeed a rather infamous pattern: There are many voices out there that describe Singleton as a general problem in code, as an anti-pattern, as dangerous, or even as evil. Still, despite the bad reputation and the many negative aspects, if used judiciously and if implemented properly, Singleton has proven to be a useful solution for representing the few global aspects in your code.

This talk tries to give a balanced overview of the Singleton pattern. I will show the cons as well as the pros and will demonstrate how to properly deal with Singletons to overcome the major disadvantages. In particular, I will show how to implement Singletons such that dependencies to implementation details are avoided, code can be easily changed and full testability is given.

software design
design patterns

Klaus Iglberger

Klaus Iglberger is a freelancing C++ trainer and consultant. He has finished his PhD in computer science in 2010 and since then is focused on large-scale C++ software design. He shares his experience in popular advanced C++ courses around the world (mainly in Germany, but also the EU and US). Additionally, he is the initiator and lead designer of the Blaze C++ math library ( and a (co-)organizer of the Munich C++ user group (