|By Debadatta Mishra||
|July 18, 2012 11:15 AM EDT||
A few days ago when I was in my home town, one of my sub-juniors from my colleague attended an interview in an MNC and was severely injured in that interview process. I mean he could not qualify the interview because of the difficult questions fired by the interview panel. When I came back to Bangalore, he sharedthe embarrassing situation he confronted during the technical interview. Based upon his experience today I am writing this article on the Singleton Design Pattern. By the way my junior colleague has nearly four years of experience in Java. One of the controversial questions he faced was "What is the Singleton Design Pattern and how will you write a robust singleton class? " However let me give you the basic and critical outlines of the Singleton Design Pattern frequently used at the time of project/product development.
As you know the Singleton design pattern comes under the category of "Creational Pattern". The basic principle says there should be one and only one instance of a class at any point of time irrespective of multiple invocations of a class. There are many concepts and designs behind this principle. Many developers assume different ways of implementing Singleton in Java. Some developers do not like this design at all. However we should concentrate on this design and other factors are completely irrelevant for us. Let us analyze this design from various perspectives.