This is probably a pretty dumb question, but earlier today I ran into some code where an external class was storing a reference to a Singleton class instance (in a private field), and was using this reference instead of getting the instance from the Singleton class every time.
At first it looked like bad design to me, because it adds a field to a class for nothing, but is there another reason why you shouldn't do this (or should do this)?
Small code example to illustrate:
enum SomeSingletonObject { INSTANCE; public void someMethod() {...} } class AnotherObject { private SomeSingletonObject sso; public AnotherObject() { this.sso = SomeSingletonObject.INSTANCE; } public void someMethod() { sso.someMethod(); // instead of // SomeSingletonObject.INSTANCE.someMethod(); } }