627
Comment:
|
← Revision 21 as of 2008-11-15 13:59:47 ⇥
680
converted to 1.6 markup
|
Deletions are marked like this. | Additions are marked like this. |
Line 3: | Line 3: |
= Singleton = | = Pattern Programming = |
Line 5: | Line 5: |
=== classmethod === ---- ''' pro ''' |
''I believe we should defer to C2 for the main ideas about Patterns. I believe we should apply the Wiki:BridgePattern. Use C2 to describe the pattern itself, and then show it here in it's Python-specific glory. There's seems to be little point in attempting to recreate the depth of C2 here.'' |
Line 9: | Line 7: |
You can use both as simple class or as a singleton... | See also : * [[http://dales.rmplc.co.uk/Duncan/accu/pythonpatterns.html/|Patterns in Python by Duncan Booth]] |
Line 11: | Line 10: |
---- ''' cons ''' |
* Wiki:DesignPatternsBook * Thinki:PythonPatterns |
Line 14: | Line 13: |
=== GoF === | |
Line 15: | Line 15: |
* SingletonProgramming * ProxyProgramming |
|
Line 16: | Line 18: |
{{{ #!python # Code is Public Domain. class Singleton: _singleton = None def getSingleton(cls): if not Singleton._singleton: Singleton._singleton = cls() return Singleton._singleton getSingleton = classmethod(getSingleton) class Test(Singleton): def test(self): print self.__class__,id(self) t1 = Test.getSingleton() t2 = Test.getSingleton() t1.test() t2.test() }}} |
=== Other === * DelegationEventModel * StateProgramming * EnumerationProgramming |
Pattern Programming
I believe we should defer to C2 for the main ideas about Patterns. I believe we should apply the BridgePattern. Use C2 to describe the pattern itself, and then show it here in it's Python-specific glory. There's seems to be little point in attempting to recreate the depth of C2 here.
See also :
GoF