Multiton pattern: Difference between revisions

Content deleted Content added
Bender the Bot (talk | contribs)
m Drawbacks: HTTP to HTTPS for Blogspot
 
(2 intermediate revisions by one other user not shown)
Line 15:
 
==Drawbacks==
This pattern, like the [[Singleton pattern]], makes [[unit testing]] far more difficult,<ref>{{Cite web | url=httphttps://googletesting.blogspot.com/2008/11/clean-code-talks-global-state-and.html |title = Clean Code Talks - Global State and Singletons}}</ref> as it introduces [[global variables|global state]] into an application.
 
With garbage collected languages it may become a source of memory leaks as it introduces global strong references to the objects.
Line 67:
 
// Sample usage
public static void Main(string[] args)
{
varMultiton m0 = Multiton.GetInstance(MultitonType.Zero);
varMultiton m1 = Multiton.GetInstance(MultitonType.One);
varMultiton m2 = Multiton.GetInstance(MultitonType.Two);
 
Console.WriteLine(m0);