CppCon 2020 has ended
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 Engineering Lead, Bloomberg
Pete Muldoon has been using C++ since 1991. Pete has worked in Ireland, England and the USA and is currently employed by Bloomberg as a senior Engineering Lead. A consultant for over 20 years prior to joining Bloomberg, Peter has worked on a broad range of projects and code bases... Read More →

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