This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Sorry, I don't fully understand the question. Could you please elaborate? What do you need this for?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Dec 24, 2002
I have been recently asked about singleton pattern which i aptly explained. Following that I was asked "how is singleton pattern implemented in JVM?" I know that we can implement the singleton pattern for class A by checking if an instance is already present and then create it. But i myself did not get that question..so posted it if anyone of you could help me out...
There are numerous variants. You can use lazy instantiation, so the Singleton is created only the first time you call getInstance(). In a web container, class reloading may mess up a Singleton based on static variables and you may be better off using the application context instead. This example allows only one instance of a class; sometimes you want one instance per possible state, the GoF book uses the example of using objects to represent the 26 letters of the alphabet; your Singleton will then have 26 instances, one for each letter. - Peter [ December 30, 2002: Message edited by: Peter den Haan ]