User Tools

Site Tools


design_patterns

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
design_patterns [2012/06/10 14:10]
mantis [Singleton]
design_patterns [2012/06/10 14:10] (current)
mantis
Line 1: Line 1:
 +===== Constructor =====
  
 +===== Decorator =====
 +
 +===== Null object =====
 +
 +===== Observer =====
 +
 +===== Proxy =====
 +
 +===== Singleton =====
 +
 +Aka Borg pattern
 +
 +<code python>
 +
 +class Singleton:
 +    __shared_state = {}
 +    def __init__(self):​
 +        self.__dict__ = self.__shared_state
 +
 +s1 = Singleton()
 +s1.x = 1
 +s2 = Singleton()
 +s2.x # 1
 +</​code>​
design_patterns.txt ยท Last modified: 2012/06/10 14:10 by mantis