Common Uses
- The Abstract Factory, Builder, and Prototype patterns can use Singletons in their implementation.
- Facade Objects are often Singletons because only one Facade object is required.
- State objects are often Singletons.
- Singletons are often preferred to global variables because:
- They do not pollute the global name space (or, in languages with namespaces, their containing namespace) with unnecessary variables.
- They permit lazy allocation and initialization, whereas global variables in many languages will always consume resources.
Read more about this topic: Singleton Pattern
Famous quotes containing the word common:
“The wildest dreams of wild men, even, are not the less true, though they may not recommend themselves to the sense which is most common among Englishmen and Americans to-day. It is not every truth that recommends itself to the common sense. Nature has a place for the wild clematis as well as for the cabbage. Some expressions of truth are reminiscent,others merely sensible, as the phrase is,others prophetic.”
—Henry David Thoreau (18171862)
“This is really the common mentality of prisoners: they read with great attention all the articles that deal with illnesses and send away for treatises and be your own doctor or emergency treatments and end up by discovering that they have at least 300 or 400 illnesses, whose symptoms they are experiencing.”
—Antonio Gramsci (18911937)