C++ Singletons Are Not Evil - You’re Just Using Them Wrong

Online Workshops + Training Sessions Available through April-June 2026 from only £150 ($200) 14 Sessions Available on a range of topics. Student Rates available from only £45/$60! US and EU friendly session times. https://cpponline.uk/ --- Singletons Are Not Evil - You’re Just Using Them Wrong - Mostafa Mahmoud Ali - C++Online 2026 Singletons have long been branded an anti pattern in C++, blamed for untestable code, hidden dependencies, and global state headaches. But what if the problem isn’t the pattern itself, but how we implement it? This talk introduces a practical approach for transforming existing singletons in legacy codebases into unit testable, dependency friendly entities without breaking existing call sites. Using a lightweight `SingletonBase` and `ScopedSingletonState` pattern, we can preserve the familiar singleton API while enabling scoped overrides, test injection, and safe instance management. The result is a reframing of the debate: singletons are not inherently bad — they’re just hard to get right. With the right foundation, they can become a powerful and even elegant design choice in the right contexts. Attendees will leave with a drop in pattern they can apply immediately to their own projects, along with a fresh perspective on when singletons make sense. Slides: https://github.com/CppOnlineConferenc... --- Work at Hudson River Trading (HRT): https://tinyurl.com/safxfctf --- Mostafa Mahmoud Ali Senior Software Engineer with 10+ years of experience, both as a freelancer and a full-timer. Worked in different fields including Additive manufacturing, medical industries, cyber security and more. --- C++Online is the annual, online only conference for the entire C++ community. The conference is designed to provide a more accessible option for C++ developers who might find attending other international C++ conferences more difficult or financially restrictive, at a time of year where we traditionally see less in-person cpp conferences due to weather, holidays and other restrictions. The Online C++ Conference - https://cpponline.uk   / cpponline   https://x.com/cpponline https://www.facebook.com/profile.php?...   / cpponline   https://mastodon.social/@cpponline https://bsky.app/profile/cpponline.bs... --- Streamed & Edited by Digital Medium Ltd - online.digital-medium.co.uk --- C++Online - The Online C++ Conference organized by Shaved Yaks: https://shavedyaks.com/ & Digital Medium: https://events.digital-medium.co.uk --- #cpp #cplusplus #cpponline #cppprogramming #cplusplusprogramming #softwaredevelopment #softwareengineering #coding #code #computerscience #technology #technews #programming #programmer