File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Singleton Design pattern

 
sreedhar Lackka
Ranch Hand
Posts: 154
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
sreedhar Lackka
Ranch Hand
Posts: 154
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your quick response.

Could you give me some more example, I think your clear with my question.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic