Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Singleton pattern
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Criticism == Some consider the singleton to be an [[anti-pattern]] that introduces [[global variables|global state]] into an application, often unnecessarily. This introduces a potential dependency on the singleton by other objects, requiring analysis of implementation details to determine whether a dependency actually exists.<ref name="google">{{cite web |title=Why Singletons Are Controversial |url=https://code.google.com/archive/p/google-singleton-detector/wikis/WhySingletonsAreControversial.wiki |archive-url=https://web.archive.org/web/20210506162753/https://code.google.com/archive/p/google-singleton-detector/wikis/WhySingletonsAreControversial.wiki |archive-date=6 May 2021 |access-date=28 August 2021 |website=Google Code Archive}}</ref> This increased [[Coupling (computer programming)|coupling]] can introduce difficulties with [[unit testing]].<ref name="button">{{cite news |last1=Button |first1=Brian |date=25 May 2004 |title=Why Singletons are Evil |work=Being Scott Densmore |publisher=Microsoft |url=https://docs.microsoft.com/en-us/archive/blogs/scottdensmore/why-singletons-are-evil |access-date=28 August 2021 |archive-url=https://web.archive.org/web/20210715184717/https://docs.microsoft.com/en-us/archive/blogs/scottdensmore/why-singletons-are-evil |archive-date=15 July 2021}}</ref> In turn, this places restrictions on any abstraction that uses the singleton, such as preventing [[Concurrency_(computer_science)|concurrent]] use of multiple instances.<ref name="button" /><ref>Steve Yegge. [http://steve.yegge.googlepages.com/singleton-considered-stupid Singletons considered stupid], September 2004</ref><ref name="googletesting.blogspot.com">Hevery, Miško, "[http://googletesting.blogspot.com/2008/11/clean-code-talks-global-state-and.html Global State and Singletons]", ''Clean Code Talks'', 21 November 2008.</ref> Singletons also violate the [[single-responsibility principle]] because they are responsible for enforcing their own uniqueness along with performing their normal functions.<ref name="button" />
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Singleton pattern
(section)
Add topic