Hacker News new | ask | show | jobs
by malkia 5534 days ago
Singleton's are fine, as long as you don't know they are such. For example calling a function, that does lazy initialization (first time init) - is really good - e.g. not requiring certain initialization is sometimes really practical, and does not introduce messiness in your code. Most importantly does not require putting that initialization code throughout every application that you might use.

For example, we use at work DEJA Insight Profiler, and you can directly put profile probes (C++) with DEJA_CONTEXT("SomeFunction") - it's using RAII to mark start/end of the probe. But the point is there is no explicit call to DEJA_INIT, or DEJA_CLOSE, etc. But this only works if the DEJA main application is loaded.