Singleton is definitely one of the most misused and abused patterns out there. Many of us have been infected with Singletonitis at one point or another. Curiously, its close c
How about a class with a single instance, but without global access:
public class SingleInstance
{
private static boolean exhausted = false;
public SingleInstance()
{
if (exhausted)
{
throw new IllegalStateException("only one instance allowed");
}
exhausted = true;
[...]
}
[...]
}
This avoids the problems of Singleton and MonoState, while it enforces and clearly communicates that there is only one instance.