Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Singleton described to a simpleton

 
Donald R. Cossitt
buckaroo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cannot find reference to 'singleton' in any manual I have currently (at least directly) and Google search gives C#, ASP, C++ and Delphi only (maybe they're the same?).
Somebody point to an URL, book, give two bits...?
TIA
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Singleton" is a more or less language-independent design pattern, documented all over the place on the Web. Here's perhaps the definitive discussion from the seminal Portland Pattern Repository.
Here's a reasonable Java interpretation.
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Donald R. Cossitt:
I cannot find reference to 'singleton' in any manual I have currently (at least directly) and Google search gives C#, ASP, C++ and Delphi only (maybe they're the same?).
Somebody point to an URL, book, give two bits...?
TIA

A Google query for "java singleton" returns 68,100 hits.
JavaWorld (very good source) along has 111 articles about singletons.
 
Vinod Venkatasubramanian
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The book on Design Patterns by the Gang of 4 discusses this pattern.
One nice real-world example in Windows is the "Run" dialog box (Start->Run)... how many ever times you click on 'Run', the same dialog box is returned, ie, the handle to the same window.
 
Donald R. Cossitt
buckaroo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ernst, Eugene, Vinod. This was most helpful. Buy yourself a beer on me. :roll:
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We also have an entry for Singleton in our FAQ: http://test.javaranch.com/wiki/view?SingletonPattern
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic