DotNetKick.com is an open-source project. Please report any bugs and let us know your great suggestions. Currently running svn revision 620 (rss)

Kick Spy!, Kick Zeitgeist and Kick Widgets

16
kicks
published 1 year, 8 months ago, submitted by JamesCurran 1 year, 8 months ago

honestillusion.com — Thoughts on the Singleton Pattern (Executive summary: Don't!)

Add a comment 5 comments | category: | Views: 0 | Get KickIt image code
tags: , , | tag it

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:

Comments:
"Don't use a singleton."
"Why?"
"They're pretty much the same as global variables and static classes. Use those instead."
"Well, if they're pretty much the same, then why not use a singleton?"
"..."

Also: Author notes he fixed some spelling and "grammer" problems.
posted by yesthatmcgurk yesthatmcgurk 1 year, 8 months ago
For extra lulz, here's the author and submitter: http://honestillusion.com/photos/rnc/picture2650.aspx
posted by yesthatmcgurk yesthatmcgurk 1 year, 8 months ago
Actually, that isn't me, but a friend of mine (I took the picture)

And I do say why to not use a singleton: " If you are going to have to deal with all those problems anyway, you might as well choose the method which is both the most easily understood, most efficient, and requires the least typing."
posted by JamesCurran 1 year, 8 months ago
I'm using a singleton as a memory store for a collection of objects that are constructed from the database.
This is used in a web app. The singleton pattern provides a nice way to store a singular set of data that is loaded from the DB once without having to continually hit the DB for accessing the same information.

Singleton has a purpose and it serves itself well in the web app model.
posted by photoz 1 year, 8 months ago
Unless you are using your singleton with great care in the web app area, you will find that it does anything but serve well.

http://aabs.wordpress.com/2007/03/08/singleton-%e2%80%93-the-most-overused-pattern/

think twice before you opt for singleton. And if after you thought twice you still mean to use it - make it bullet-proof. Then come back and tell us if the effort was worth it to use the pattern.
posted by aabs 1 year, 8 months ago



information Login or create an account to comment on this story
 

Sponsored Link: www.carlist.ie

Search:

Ads via The Lounge