Link Details

Link 153090 thumbnail
User 212108 avatar

By legendx
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
  • 2370
  • 4
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


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.

Apache Hadoop
Written by: Piotr Krewski
Featured Refcardz: Top Refcardz:
  1. Play
  2. Akka
  3. Design Patterns
  4. OO JS
  5. Cont. Delivery
  1. Play
  2. Java Performance
  3. Akka
  4. REST
  5. Java