What do you call "singleton", which allows the public constructor to create additional instances?

I am creating a class that supports the use of Singleton (one instance is available), but it also supports the normal use of the instance (via a public constructor).

If you only need one, use it. If you want 5, upgrade them.

Obviously, I cannot name this singleton, or some other developer will come and make my constructor non-public. What can I call this to indicate how to use it? The naming is tough.

Some guesses for your entertainment: "StaticallyAvailable"? "ThreadReady"? "SingletonOptional"?

+3
source share
5

, " ". .

+3

, . , , "" . .

, , Singleton, - . .

+1

?

(esp, , , /)

+1

This does not look like a singleton for me, it sounds like a regular class that always has at least one instance. Calling this singleton and writing the code as if it were one (for example private static MySingleton instance = new MySingleton();) is confusing - somehow separate the “always present” instance from your class definition. Demonstrate in your implementation that this is a normal class that always always has at least one instance around.

+1
source

You can create an instance of the default instance.

private TheClass defaultInstance;
public Default{ get{ return defaultInstance??(defaultInstance = new TheClass());}
0
source

All Articles