HN user

enki42

3 karma

Passionated by programming.

Posts0
Comments3
View on HN
No posts found.

I understand your point of view, but that kind of problem is application specific. When we have to deal with these constraints, of course the use of a Singleton is dumb.

If I had to deal with these, I'll change my implementation to fit to my needs. That's all.

Maybe the term "generic" was too heavy for the use cases I described.

Why should a Singleton be thread safe? Nothing says that it will be used in a multi-threaded environment... For me a Singleton must fulfill the specification given by the Gang of Four.

I'm not saying that it should not be thought thread safe, I just say that it's not the point here.

Hi everyone! I'm the author of this blog.

I agree with most of you that Singleton can lead to destroy a design. I just think that we should not ban something globally, and I'm sure that this (anti-?)pattern can be useful sometimes.

The aim of this post was not to encourage people to use Singleton, but to show how C++11 can improve our way to write classical code. I just took a simple example of singleton.