|
| |
| | Singleton pattern - Wikipedia, the free encyclopedia |
 | | In software engineering, the singleton design pattern is designed to restrict instantiation of a class to one (or a few) objects. |  | | A possible C++ solution (also known as Meyers singleton) where the singleton is a static local object (note: this solution is not thread-safe and is designed to give an idea of how singletons work rather than a solution usable in large-scale software project). |  | | In a prototype-based programming language, where objects but not classes are used, a "singleton" simply refers to an object without copies or that is not used as the prototype for any other object. |
|
http://en.wikipedia.org/wiki/Singleton_pattern
(758 words)
|
|
| |
| | Design Pattern Synopses |
 | | The Composite pattern also allows the objects in the tree to be manipulated in a consistent manner, by requiring all of the objects in the tree to have a common superclass or interface. |  | | The Strategy pattern is often used with the Null Object pattern. |  | | The Null Object pattern is often used with the Strategy pattern. |
|
http://www.mindspring.com/~mgrand/pattern_synopses.htm
(4381 words)
|
|
| |
| | Implementing the Singleton Pattern |
 | | Patterns have names and descriptions that describe how to implement a particular pattern, and usually there is information that describes the benefits and consequences of using a specific pattern. |  | | Patterns are named solutions or strategies to problems that have already been solved. |  | | A pattern is a general solution to a category of problem. |
|
http://www.developer.com/net/print.php/972041
(958 words)
|
|
| |
| | Introducing the singleton - "The Single Java Object" |
 | | A singleton is an object that cannot be instantiated. |  | | For those who haven't heard of design patterns before, or who are familiar with the term but not its meaning, a design pattern is a template for software development. |  | | The singleton pattern can be applied in any language, but since we're all Java programmers here (if you're not, shame!) let's look at how to implement the pattern using Java. |
|
http://www.javacoffeebreak.com/articles/designpatterns
(1187 words)
|
|
| |
| | [No title] |
 | | The singleton pattern applies to the many situations in which there needs to be a single instance of a class, a single object. |  | | One possible disadvantage to this pattern is that you may lose some functionality contained in the lower level of classes, but this depends on how the facade was designed. |  | | The compilers that we use everyday to process the computer code that we have written is a prime example of the facade pattern in action. |
|
http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/patterns/tutorial.html
(760 words)
|
|
| |
| | When is a Singleton not a Singleton? |
 | | The Singleton should not be seen as way to implement global variables in the Java programming language; rather, along the lines of the factory design patterns, the Singleton lets you encapsulate and control the creation process by making sure that certain prerequisites are fulfilled or by creating the object lazily on demand. |  | | The Singleton's purpose is to control object creation, limiting the number to one but allowing the flexibility to create more objects if the situation changes. |  | | Thread-safe code is particularly important in Singletons, since that Design Pattern is meant to give the user a single point of access that hides the complexities of the implementation, including multithreading issues. |
|
http://java.sun.com/developer/technicalArticles/Programming/singletons
(3004 words)
|
|
| |
| | Implementing Design Patterns in C# - Singleton Pattern |
 | | First case Singleton can be used in a data repository or data collection where creation of more than one object can be resource wastage. |  | | Code is a string value, it is used to demonstrate that the object is shared b/w references and change made to this field through one reference can be realized through other reference. |  | | Property Reference returns the number of reference referencing our shared object while Code property can be used to set/get the code string of shared object. |
|
http://www.c-sharpcorner.com/Code/2003/Jan/SingletonPattern.asp
(730 words)
|
|
| |
| | Design pattern (computer science) - Free Encyclopedia |
 | | A design pattern is an abstraction of a solution for a particular class of problems. |  | | Design patterns represent the accumulated knowledge of the community of software developers of standardised solutions to recurring problems. |  | | Singleton pattern - an object which is unique in its kind in the whole system |
|
http://www.wacklepedia.com/d/de/design_pattern__computer_science_.html
(449 words)
|
|
| |
| | Exploring the Singleton Design Pattern (Building Distributed Applications) |
 | | In most cases, it is very easy to develop a singleton without a parent class, and adding sub-classing functionality adds a new level of complexity that is generally not needed anyway. |  | | In the course of developing software applications, repetitive patterns emerge as the application is developed. |  | | The Singleton pattern was formally defined in the classic reference, Design Patterns: Elements of Reusable Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (also known as the Gang of Four, or GoF). |
|
http://msdn.microsoft.com/library/en-us/dnbda/html/singletondespatt.asp?frame=true&_r=1
(2839 words)
|
|
| |
| | ONJava.com -- The Singleton as a Network Management Pattern |
 | | The Singleton pattern is often used where you want just one (and only one) instance of a class in a given JVM. |  | | This is a pattern example that helps in reducing unnecessary future code changes. |  | | As is well described in Larman's book, the major merit of using patterns is the speed at which fairly complex and complete software can be written. |
|
http://www.onjava.com/pub/a/onjava/2004/10/27/NMSingleton.html
(1351 words)
|
|
| |
| | Implementing the Singleton Pattern in C# |
 | | Implementing the Singleton Pattern in C# Implementing the Singleton Pattern in C# The singleton pattern is one of the best-known patterns in software engineering. |  | | There are various different ways of implementing the singleton pattern in C#. |  | | To avoid these problems, I'd suggest using the second pattern listed on the page - just use a simple lock, and go through the check each time, building the instance in the method/property if it hasn't already been successfully built. |
|
http://www.yoda.arachsys.com/csharp/singleton.html
(2111 words)
|
|
| |
| | Singleton Pattern |
 | | UnitTests of objects which use the singleton property are initialized to use a test implementation of the interface. |  | | However, using a Singleton is an implementation decision which should not affect the interface of the given class. |  | | Singletons do not create unnatural interdependencies made by passing a context object around, where every piece of code will bind to everything in the context object. |
|
http://c2.com/cgi/wiki?SingletonPattern
(4926 words)
|
|
| |
| | ONJava.com -- Using the Singleton Pattern |
 | | The Singleton pattern is one of the simpler design patterns in the book Design Patterns: Elements of Reusable Object-Oriented Software. |  | | A class that implements the Singleton pattern is called a Singleton class. |  | | This pattern is effective for limiting the maximum number of instances of a class to exactly one. |
|
http://www.onjava.com/pub/a/onjava/2003/08/27/singleton.html
(1248 words)
|
|
| |
| | Simply Singleton |
 | | The singleton implemented in Example 1 is easy to understand. |  | | As you can see from the preceding discussion, although the Singleton pattern is one of the simplest design patterns, implementing it in Java is anything but simple. |  | | The other solution is to put your singleton class in an explicit package, so classes in other packages (including the default package) cannot instantiate singleton instances. |
|
http://www.javaworld.com/javaworld/jw-04-2003/jw-0425-designpatterns.html
(854 words)
|
|
| |
| | Implementing the Singleton Pattern in Java |
 | | Note that by separating the wrapper from the actual implementation, it is possible to both A) provide a well known access point for the Singleton instance and B) allow greater flexiblity as to which subclass to use to create the instance. |  | | Note that the wrapper could actually wrap a Singleton interface, rather than a concrete class. |  | | Second, we create static wrapper for the Singleton class. |
|
http://radio.weblogs.com/0122027/stories/2003/10/20/implementingTheSingletonPatternInJava.html
(922 words)
|
|
| |
| | JOT: Journal of Object Technology - How to get a Singleton in Eiffel? Karine Arnout, Eric Bezault |
 | | We think it should be the duty of the users of the Singleton library to decide when implementing a singleton whether there should be only one instance or only one direct instance of that type; it shouldn’t be up to the authors of the library to decide. |  | | Declaring singleton as a once function does ensure that any call to this function returns the same object, but nothing prevents the program from creating another instance of class SINGLETON somewhere else in the code, which breaks the whole idea of a singleton. |  | | Finally, this code is not a library component: it is just an example implementing (or trying to implement) the singleton pattern. |
|
http://www.jot.fm/jot/issues/issue_2004_04/article5/index_html
(3741 words)
|
|
| |
| | singleton pattern usage |
 | | After reading about singleton I was thinking if I could use this pattern to suite my needs. |  | | I would suggest a separate ConnectionFactory or ConnectionManager class, which would be a singleton and cache connection instances. |  | | The only reason I did not use static methods is because I read that is a bad design to use it too much. |
|
http://www.javaworld.com/javaforums/showflat.php?Board=TheoryPractice&Number=4635
(602 words)
|
|
| |
| | design:singleton_pattern [phpPatterns] |
 | | The singleton pattern applies to the situation where you need a single, global instance of a class. |  | | The easiest way to understand a singleton pattern is by example. |  | | But first we have to overcome a small problem in PHP - the lack of static class variables (something that’s coming in the Zend 2 engine. |
|
http://www.phppatterns.com/docs/design/singleton_pattern
(573 words)
|
|
| |
| | Singleton Session Pattern |
 | | That is true in case you tie your pattern to the EJB implementation and do not think about abstraction and code reusability outside of a specific implementation itself. |  | | EJB Design Patterns was the #2 book at Java One 2002, and held the #1 Java book position on Amazon.com for weeks since the book was released in March. |  | | This pattern helped me quite a bit when I have enabled the framework that I wrote with Struts, so my frameworks modules could be accessed over the web and benefit from Struts features. |
|
http://www.theserverside.com/patterns/thread.tss?thread_id=25624
(1668 words)
|
|
| |
| | D Melodic Minor Accidental : Singleton Pattern |
 | | IIRC, the pattern I'm using the Init() method is the double-check locking pattern. |  | | Neil: there are also issues with the double null checking pattern with the.net memory model. |  | | If you want to, you can create a private static lock object that you have to acquire before you even test if the sharedOnly field is null or not (and retain it until you've finished assigning). |
|
http://blogs.msdn.com/theoy/archive/2004/05/20/136528.aspx
(1521 words)
|
|
| |
| | Implementing the Singleton Pattern in C# |
 | | Here as the Singleton instance is referenced by a private static member variable, therefore the instantiation of the class is not created until the class is first referenced invoking Instance property. |  | | In this scenario we can use one of the singleton pattern that are commonly available. |  | | There can be two different threads that are evaluated for the check if (instance==null) and found it to be true, then both will create instances, this violates the singleton pattern. |
|
http://www.codersource.net/published/view/293/implementing_the_singleton_pattern_in.aspx
(701 words)
|
|
| |
| | [No title] |
 | | The Singleton pattern places responsibility for object *creation* squarely in the Singleton class. |  | | In the vanilla version of the pattern, Instance limits you to exactly one instance of the Singleton class (the User class in this case). |  | | If your Singleton objects ever need to do such cleanup, they probably have to wait until just before the program terminates. |
|
http://www.research.ibm.com/designpatterns/pubs/ph-jun96.txt
(2448 words)
|
|
| |
| | The Singleton Pattern Revisited |
 | | These included how to construct a singleton when the class has a non-trivial constructor with arguments that are calculated at run-time, and how to use the singleton in a multi-threaded environment. |  | | The next question he had was whether it was safe to use the singleton code I provided in a multi-threaded environment. |  | | The "Double-Checked Locking Pattern" is broken per Meyers and Alexandrescu.... |
|
http://www.devarticles.com/c/a/Cplusplus/The-Singleton-Pattern-Revisited
(488 words)
|
|
| |
| | Creating a real singleton class in Delphi 5 |
 | | The programmer is relieved of the task of enforcing the pattern -- that's good -- but the programmer may also be unaware of the special nature of the class, which is bad. |  | | A singleton is a class that supports the creation of just one object. |  | | Articles about singleton classes are rare but there are a few on the Internet. |
|
http://community.borland.com/article/0,1410,22576,00.html
(1430 words)
|
|
| |
| | Ed's Blog : Singleton pattern for ASP.NET |
 | | The solution is to implement the singleton to link the instance of your class to the specific HTTP Context instead of making it a static variable. |  | | The following code is for a singleton class that can be used in both an ASP.NET app and a Winforms app, if a context is not found, a static variable is created as in the default implementation of the pattern. |  | | To implement the singleton pattern (GoF) in ASP.NET you need to put in a bit of a twist if you want to have once instance of an object per web request. |
|
http://dotnet.org.za/eduard/archive/2004/07/07/2609.aspx
(195 words)
|
|
| |
| | Page 3 - The Singleton Pattern Revisited |
 | | With the Singleton class, the creation process of the object that has to become the singleton has been extrapolated into policy classes. |  | | You can see in the singleton code that there are two policies given for the creation of an object inside the singleton class (CreateLeaking and CreateMeyers). |  | | The reason for this is that there might be different reasons to construct the object in different ways. |
|
http://www.devarticles.com/c/a/Cplusplus/The-Singleton-Pattern-Revisited/2
(600 words)
|
|
| |
| | Singleton Design Pattern |
 | | The Delphi implementation for the pattern originates from White Ants. |  | | Consider for example a class TProgressor which could be used as a low level service to deal with time consuming processes. |  | | Applying the singleton pattern to this class results in the following interface: |
|
http://www.castle-cadenza.demon.co.uk/single.htm
(566 words)
|
|
| |
| | Singleton Pattern |
 | | Below is a simple implementation of this pattern. |  | | The Singleton design pattern's functionality is pretty much what you would expect given its name, 'Singleton'. |  | | - So you want to learn about the Singleton Design Pattern eh? |
|
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=7
(213 words)
|
|
| |
| | Singleton Design Pattern in C# and VB.NET |
 | | code demonstrates the Singleton pattern as a LoadBalancing object. |  | | The classes and/or objects participating in this pattern are: |  | | code demonstrates the Singleton pattern which assures only a single instance (the singleton) of the class can be created. |
|
http://www.dofactory.com/Patterns/PatternSingleton.aspx
(192 words)
|
|
| |
| | [Tutor] singleton pattern |
 | | This book is not for beginners, however, and all the example code is in C++ or Smalltalk. |  | | For those interested in seriously pursuing software development I highly recommend the book "Design Patterns: Elements of Reusable Object Oriented Software" by the so-called Gang of Four (Gamma, Helm, Johnson, Vlissides). |  | | The patterns are really good to know and are not language specific. |
|
http://mail.python.org/pipermail/tutor/2001-May/005864.html
(273 words)
|
|
| |
| | Singleton Pattern |
 | | Determines whether the singleton class will implement the Serializable interface |  | | Would you like to have the singleton field initialized dynamically |  | | Select "Yes" to initialize the singleton field dynamically, or select "No" to initialize the singleton field statically. |
|
http://www.instantiations.com/codepro/ws/docs/features/patterns/singleton_pattern.html
(442 words)
|
|
| |
| | PatternStories: Singleton Pattern |
 | | Though that doesn't help in understanding the pattern itself JasonGorman |  | | -- [DavidMcReynolds] ---- Though that doesn't help in understanding the pattern itself [JasonGorman] ---- Here is a thread safe lazy instantiated Singleton class |  | | I have seen too many instances of a straight port of the GoF C++ code to Java and would say that any discussion of the Singleton pattern in Java must at least provide a threading disclaimer. |
|
http://wiki.cs.uiuc.edu/patternStories/SingletonPattern
(356 words)
|
|
| |
| | Singleton Pattern |
 | | This code pattern is called the singleton pattern because it constructs a single instance of the class. |  | | program to use the singleton pattern to represent the |  | | The implementation of the singleton pattern shown above suffers from an annoying defect: the class definition for |
|
http://www.cs.rice.edu/~cork/teachjava/2002/notes/current/node26.html
(131 words)
|
|
| |
| | Singleton pattern |
 | | > Dear expert< > > Is the following version of singleton pattern thread-safe? |  | | To add to Kevin's reply: * The _creation_ of the singleton is thread-safe, because it's done during class loading, which is sychronized in the class loader. |  | | > * The _creation_ of the singleton is thread-safe, because it's done > during class loading, which is sychronized in the class loader. |
|
http://www.codecomments.com/message245257.html
(660 words)
|
|
| |
| | Simply Patrick: June 2005 彙整 |
 | | Timers: Comparing the Timer Classes in the.NET Framework Class Library -- MSDN Magazine, February 2004 |  | | Implement Singleton Pattern by Generic (in C# 2.0) |  | | Behind the Scenes: Discover the Design Patterns You're Already Using in the.NET Framework -- MSDN Magazine, July 2005 |
|
http://baby.homeip.net/patrick/archives/2005/06/index.php
(1145 words)
|
|
| |
| | JavaScript: The Singleton Design Pattern |
 | | Singleton is probably the most widely used design pattern in Java. |  | | For some reason, not many people use the Singleton pattern in JavaScript, despite the fact that it is extremely simple to use and implement. |  | | The intent of the Singleton pattern as defined in |
|
http://dhtmlkitchen.com/learn/js/singleton
(273 words)
|
|
| |
| | [Tutor] singleton pattern |
 | | The object reference (pointer) has allready been created by the time we execute the constructor (the self in __init__(self)). |  | | Arguably this is the important property of the singleton pattern. |  | | So there is absolutely nothing we can do about the definition of class Singleton that will magically cause >>> x = Singleton() >>> y = Singleton() >>> id(x) == id(y) 1 (Not without completely unpythonic namespace hackery) So, there are two alternative approaches. |
|
http://mail.python.org/pipermail/tutor/2001-May/005863.html
(262 words)
|
|
| |
| | singleton - definition of singleton by the Free Online Dictionary, Thesaurus and Encyclopedia. |
 | | Games A playing card that is the only one of its suit in a player's hand. |  | | singleton - a single object (as distinguished from a pair) |  | | This information should not be considered complete, up to date, and is not intended to be used in place of a visit, consultation, or advice of a legal, medical, or any other professional. |
|
http://www.thefreedictionary.com/singleton
(213 words)
|
|
| |
| | C# - Singleton Pattern |
 | | Singleton Pattern - syed zubair 09-05 07:16 AM |  | | Singleton Pattern - Patrick Riva 09-05 07:58 AM |  | | Here are the links - Suneetha Nambari 09-06 02:20 AM |
|
http://www.eggheadcafe.com/forums/Forumpost.asp?ID=33780&INTID=2
(138 words)
|
|
|