Link Details

Link 153090 thumbnail
User 212108 avatar

By legendx
via mikebernat.com
Published: Feb 01 2009 / 18:49

Often one of the first patterns that young developers encounter, the singleton solves a very sloppy, dangerous, and nightmarish practice known as global variables. There are components in nearly every application that need to be accessed everywhere. The younger developers might be tempted to declare a debug variable as global, and just access it where he/she pleases. You will learn later on in the project that this makes maintaining the application very frustrating.
  • 8
  • 10
  • 2303
  • 4

Comments

Add your comment
User 211643 avatar

zynasis replied ago:

0 votes Vote down Vote up Reply

oh my god... this has been done a thousand times before

User 306525 avatar

Dave Newton replied ago:

0 votes Vote down Vote up Reply

Of course it doesn't come under fire for *its* usefulness--that wouldn't make any sense. And the reasons for not liking it go quite a bit beyond "nit-picky" :/

User 212108 avatar

legendx replied ago:

0 votes Vote down Vote up Reply

@newton_dave

Apologies for the horribly constructed sentence. I think what I was trying to convey was the degree of it's effectiveness often comes under fire. I stand by the closing statement. I haven't seen a convincing argument that showed that singletons don't have their place. One of my key points was to be mindful of the situation you're using it in. If you abide by that and use the pattern in situations where you're not trying to force it than I think it is very effective.

Thanks for the input.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Spring Integration
Written by: Soby Chacko
Featured Refcardz: Top Refcardz:
  1. Search Patterns
  2. Python
  3. C++
  4. Design Patterns
  5. OO JS
  1. PhoneGap
  2. Spring Integration
  3. Regex
  4. Git
  5. Java