CppCon 2020 has ended
Back To Schedule
Friday, September 18 • 09:00 - 10:00
Retiring the Singleton Pattern: Concrete Suggestions for What to use Instead

Log in to save this to your schedule, view media, leave feedback and see who's attending!

Feedback form is now closed.
“The worst part of this whole topic is that the people who hate singletons rarely give concrete suggestions for what to use instead.” - stackoverflow

In this talk, we will explore just such an approach that will transform currently untestable code containing underlying singletons with a fully testable solution. These code changes are transparent to the original callers of that function so no calling code changes are required.

This approach will be further expanded to handle multiple interdependent singletons. The replacement of error prone specific order of initialization calls to the singletons will be exchanged for "hard to misuse" automatic initialization using features of the language.

A host of other potential real world problems with replacing singletons are shown with solutions presented for both legacy and modern C++.

This alternative approach has been successfully employed in multiple areas in Bloomberg where developers believed there was no other feasible choice.

avatar for Peter Muldoon

Peter Muldoon

Senior developer, Bloomberg
C++ Design implementation of large distributed systems.

Friday September 18, 2020 09:00 - 10:00 MDT
  • Design