• entries
    111
  • comments
    278
  • views
    155513

Collected Readings on Singletons

Sign in to follow this  
Promit

362 views

Sign in to follow this  


4 Comments


Recommended Comments

I think you could replace all of that with "Don't use Singletons. Ever. Seriously. Like, use a Monostate or something else. Dude, I'm not kidding. It's just an 'object-oriented' global."

Share this comment


Link to comment
The thing is, they push singletons in university CS "software engineering" classes. I've had arguments of several minutes with my professors about whether or not it's appropriate to use a singleton, myself arguing that it perverts proper application flow and hampers readability (as well as breaking flexibility) and them arguing that they're lazy.

Academics...

Share this comment


Link to comment
Nice one for collecting all those links together. Shall have to remember this link for the inevitable future discussion [smile]

I find that design pattern usage is in one of two extremes - over use or under use, never "just right." People religiously sticking to a pattern are just an example of those with tunnel vision that over-use something and try desperately hard to distort the world to fit that one tool...

Share this comment


Link to comment
My sarcasm detector might not be working, but I disagree that a monostate is any better than a singleton. Both are globals in disguise (though monostates are very well disguised... which might even be a problem of it's own).

Global mutable state is the major issue I think, since it introduces implicit dependencies between modules that use the state. You may call it a singleton, a monostate or a static variable, but they all suffer from the same problem. The solution is simple: avoid it as much as possible.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now