views:

242

answers:

4

A friend of mine was recently asked in a job interview to tell the difference between a standard singleton and a mono singleton. I have never heard the term before and a simple google search does not return any meaningful results.

My friend suggested that it is an object where the constructor is public but all the members are static. This seems a little silly to me as it would simply be a static object that would not require a constructor at all.

Does anyone have a better definition of a mono singleton? Is it something useful versus a standard singleton?

A: 

I know that a "singleton" can be modified to support n instances, where n is a fixed number. However, I learned that this was called a multiplton or multiton (I forgot the exact name, but it was similar to that). It could be that the interviewer wanted to get to the point that you can use something very much like the Singleton pattern to achieve n instances of the object. But if that's the case, it was an awkward way of putting it.

Thomas Owens
A: 

I've never heard the term being used before, but I'd imagine that it's used to refer to a singleton that only allows for one instance being created. (A general singleton doesn't require that, it can also give out a limited number of instances).

Either that, or it's a singleton done in mono...

Jasper Bekkers
A Singleton, as defined by the GoF, only allows for one instance. Limiting the number of instances is a generalization of Singleton.
Thomas Owens
That is absolutely correct, however, I was under the impression that this generalization was generally accepted.
Jasper Bekkers
+4  A: 

I imagine they actually meant "Monostate". I won't go into the details as they are now easily googleable (along with discussions of the difference to Singletons).

However, I will say that Monostates tend to have at least all the same problems and Singletons and should be avoided as far as possible (considering other approaches instead, such as Parameterise From Above, or dependency injection, where appropriate).

Phil Nash
+1  A: 

There's exactly one hit on google for "mono singleton" (with quotes), so I'd resolve it as a singleton used in a platform neutral DotNet framework as opposed to a "Java Singleton" or a "C++ Singleton".

Sorry, couldn't resist :)

Olaf