Singleton is one of the frequently used and easily understandable design pattern. Most of the tutorials and books give example of making the constructor as private and exposing a static method which will provide single instance. The common example they use is Runtime class of JRE.
Is making constructor as private is the only way to implement singleton pattern? Is that the best way to implement singleton pattern?
My answer is “No“. Let us take an example of JRE implementation class Math. Math is a singleton class, but the instance is not exposed as a static method. Rather they made all the methods as static.
JRE exposing Runtime class instance through a static methods instead of keeping all the methods as static because it contains native method, native methods cannot be static.
My recommendation to implement singleton pattern is: make all the methods as static, if for any reason you cannot make all the methods as static, then go for static instance approach.
I feel keeping all methods as static methods is better design and developer friendly.

Leave a comment