aspose file tools*
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
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Singleton Design pattern" Watch "Singleton Design pattern" New topic
Author

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.

Regards,
Sree
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.

Cheers
Aneesh


Cheers
Aneesh
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
Greenhorn

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: http://aspose.com/file-tools
 
subject: Singleton Design pattern
 
Similar Threads
Email and Design pattern
Singleton pattern
cloning Singleton object
Singleton without Synchronized menthod ?
Decorator Pattern