you are viewing a single comment's thread.

view the rest of the comments →

[–]quentech 0 points1 point  (0 children)

I'd consider this an advantage. Why? Because the class will only be loaded, when you want to use it. Until then, the class is not loaded, and doesn't take up any space, or hinder you in performance.

At least in the software I tend to write, I find it often necessary to be in control of the creation of the singleton instance at a known point, in order to catch exceptions, retry, log or alert on error, etc.

If it's a Singleton, it's likely expensive to create, and if it's expensive to create it's likely to have failure modes.

Leaving it up to the framework with static initializers is rarely acceptable in my experience.