Discovered one coworker repeatedly checks his singletons for null.
// definition
class Singleton
{
public:
static Singleton* Instance() {
if (!Instance_)
Instance_ = new Singleton;
return Instance_;
}
private:
Singleton* Instance_;
};
Then throughout the code base:
Singleton* instance = Singleton::Instance();
if (!instance) {
cerr << "No Singleton Available!" << endl;
abort();
}
I cannot figure out what he could have been thinking. If it's anything like some other guys I work with, it could be "It's a pointer, so you have to check it, it could change any time!"