Back To Schedule

Singletons Are Not Evil

You’re Just Using Them Wrong

14:30 - 16:00 Thursday 12th March 2026 UTC
Beginner
Intermediate
Advanced
Design

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.

View Slides

Mostafa Mahmoud Ali

Senior C++ EngineerBoston Scientefic

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.

VolumetricCondensed