3 ms·
This is a good read on singletons. http://www.object-oriented-security.org/lets-argue/singletons http://www.object-oriented-security.org/lets-argue/singleton..
by 1010011010 14y ago
This is a good read on singletons.
http://www.object-oriented-security.org/lets-argue/singletons http://www.object-oriented-security.org/lets-argue/singleton...
"Singletons are possibly the single greatest obstacle to good object-oriented design today. They are often at the root of huge intractable design flaws in large systems, and yet many programmers continue to use them and even insist that they are a good design pattern. Many programmers point to the fact that the singleton pattern is a prominent part of the book Design Patterns, but don't realize that at least one of the authors of that book (Erich Gamma) is on record saying that it shouldn't have been.
We argue that Singletons are almost always bad design and almost never needed. In the few cases where singletons seem necessary, the "environment pattern" offers a reasonable alternative. Therefore, we recommend that programmers always avoid singletons and that programming languages ban them or at least provide an option to ban them."