Once you want to have two or more worlds, it will not succeed. Say when your first release is rampant, and you want to add a parallel universe expansion kit.
In my experience, 90% of the time when marketing says “oh don’t worry, there will only be one application / window / database / user”, they are wrong.
ADD
I would also avoid using a true Singleton template with World.getInstance (), etc. This applies to rare cases when it is really an important requirement that only one of them. In your case, you use it as a convenience, not a requirement.
There is no perfect fix, YMMV, but I would consider one static method, something like
World World.getWorld(String name)
and then you call real (non-static) methods in the returned world. For V1 of your program, enable null to the default world.
Some may put this method in a class called WorldManager, or possibly indicating my age, a smarter name like Amber. :-)
source share