Use your singletons wisely - 0 views
-
I know where you live anti-pattern
- ...3 more annotations...
-
The key points here are that a class is only a singleton if all applications treat it exactly the same and if its clients can use the class without an application context.
-
"singletons are unnecessarily difficult to test and may make strong assumptions about the applications that will use them [...] I know where you live anti-pattern [...] Liskov Substitution Principle". "To decide whether a class is truly a singleton: * Will every application use this class exactly the same way? (exactly is the key word) * Will every application ever need only one instance of this class? (ever and one are the key words) * Should the clients of this class be unaware of the application they are part of?"