File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Singleton Design pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Singleton Design pattern" Watch "Singleton Design pattern" New topic

Singleton Design pattern

sreedhar Lackka
Ranch Hand

Joined: Jul 05, 2008
Posts: 154
Hi All,

Thanks in advance.

I am pretty much clear with Singleton design pattern however recently one of my friend asked by a question on this,

"How can you break singleton design pattern", could you please any one tell me how will it possible.

Aneesh Vijendran
Ranch Hand

Joined: Jun 29, 2008
Posts: 125
It depends on how you implemented it.

A common example would be:

Assume you are selecting a list of Objects from DB (Lazy Loading).

Manually go to the DB and change some field values. Your singleton list will still be returning the stale data.


sreedhar Lackka
Ranch Hand

Joined: Jul 05, 2008
Posts: 154
Thanks for your quick response.

Could you give me some more example, I think your clear with my question.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
You can't "break" the design pattern because it does not include any particular implementation design and can be implemented in many different ways.

You can only "break" an implementation of the pattern and you can't really discuss this until you also describe the design of the implementation.
Narender Reddy Soma

Joined: Jun 05, 2010
Posts: 23
I agree with Frank.

Singleton as a design pattern only explains solution and its upto developer how he implements it as per the system architecture ( clustered environment etc). So, unless we are aware of your design ,cannot comment on how it can be cracked.
I agree. Here's the link:
subject: Singleton Design pattern
jQuery in Action, 3rd edition