Totally disagree. If it weren't for Singletons, I'd have to see code with classes full of statics. Same effect, but statics are the greater evil.
To be on same page, this is the Singleton:
CODE
class Foo {
// this is the one and only instance of Foo we'll ever use
private static Foo instance = null;
// This is how the world gets the "single" instance
// using lazy init, because GoF love that
public static Foo getInstance() {
if (instance == null) { instance = new Foo(); }
return instance;
}
// this prevents the world from making their own instance.
private Foo() { }
}
class Bar {
private Foo myFoo = null;
public Bar() {
// This will not work! hah, Singleton
//myFoo = new Foo();
//this works, and every class does it this way.
myFoo = Foo.getInstance();
}
}
Basically, this solves that newbie question, how do my classes share values? It also answers the plea, I want globals in my OO design. This is meant to solve the worse evil of classes made up of static methods, which is what people would normally do if that wanted such behavior.
Found another rant about them
here.
Personally, if I see any evidence of a design pattern in the wild, I'm thrilled. However, any design can be used poorly. Looks like at Google they use it very poorly.