added external design pattern documentation links to structural patterns.

This commit is contained in:
tylerlaberge
2016-08-24 22:02:46 -04:00
parent 5af1a1ae38
commit e02d089b37
6 changed files with 18 additions and 10 deletions
+2 -1
View File
@@ -1,6 +1,8 @@
class Adapter(object): class Adapter(object):
""" """
Adapter class as part of the Adapter design pattern. Adapter class as part of the Adapter design pattern.
External Adapter Pattern Documentation: U{https://en.wikipedia.org/wiki/Adapter_pattern}
""" """
def __init__(self, adaptee, **adapted_methods): def __init__(self, adaptee, **adapted_methods):
""" """
@@ -28,4 +30,3 @@ class Adapter(object):
Get the adaptee's __dict__ Get the adaptee's __dict__
""" """
return self.__adaptee.__dict__ return self.__adaptee.__dict__
+2
View File
@@ -4,6 +4,8 @@ from abc import ABCMeta
class Bridge(object, metaclass=ABCMeta): class Bridge(object, metaclass=ABCMeta):
""" """
Base Bridge class as part of the Bridge design pattern. Base Bridge class as part of the Bridge design pattern.
External Bridge Pattern documentation: U{https://en.wikipedia.org/wiki/Bridge_pattern}
""" """
def __init__(self, implementor): def __init__(self, implementor):
""" """
+2
View File
@@ -1,6 +1,8 @@
class Composite(object): class Composite(object):
""" """
Composite class as part of the Composite pattern. Composite class as part of the Composite pattern.
External Composite Pattern documentation: U{https://en.wikipedia.org/wiki/Composite_pattern}
""" """
def __init__(self, interface): def __init__(self, interface):
""" """
+8
View File
@@ -5,6 +5,8 @@ from abc import ABCMeta, abstractmethod
class Decorator(object, metaclass=ABCMeta): class Decorator(object, metaclass=ABCMeta):
""" """
Base Decorator class that all decorator classes inherit from. Base Decorator class that all decorator classes inherit from.
External Decorator Pattern documentation: U{https://en.wikipedia.org/wiki/Decorator_pattern}
""" """
def __get__(self, instance, owner): def __get__(self, instance, owner):
""" """
@@ -23,6 +25,8 @@ class Decorator(object, metaclass=ABCMeta):
class DecoratorSimple(Decorator, metaclass=ABCMeta): class DecoratorSimple(Decorator, metaclass=ABCMeta):
""" """
A Base Decorator class for decorators with no arguments. A Base Decorator class for decorators with no arguments.
External Decorator Pattern documentation: U{https://en.wikipedia.org/wiki/Decorator_pattern}
""" """
def __init__(self, func): def __init__(self, func):
""" """
@@ -36,6 +40,8 @@ class DecoratorSimple(Decorator, metaclass=ABCMeta):
class DecoratorComplex(Decorator, metaclass=ABCMeta): class DecoratorComplex(Decorator, metaclass=ABCMeta):
""" """
A Base Decorator class for decorators with arguments. A Base Decorator class for decorators with arguments.
External Decorator Pattern documentation: U{https://en.wikipedia.org/wiki/Decorator_pattern}
""" """
@abstractmethod @abstractmethod
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@@ -63,6 +69,8 @@ class DecoratorComplex(Decorator, metaclass=ABCMeta):
class CallWrapper(DecoratorSimple): class CallWrapper(DecoratorSimple):
""" """
A Decorator for wrapping DecoratorComplex __call__ methods. A Decorator for wrapping DecoratorComplex __call__ methods.
External Decorator Pattern documentation: U{https://en.wikipedia.org/wiki/Decorator_pattern}
""" """
def __call__(self, instance, func): def __call__(self, instance, func):
""" """
+2
View File
@@ -1,6 +1,8 @@
class FlyweightMeta(type): class FlyweightMeta(type):
""" """
Flyweight meta class as part of the Flyweight design pattern. Flyweight meta class as part of the Flyweight design pattern.
External Flyweight Pattern documentation: U{https://en.wikipedia.org/wiki/Flyweight_pattern}
""" """
def __new__(mcs, name, bases, attrs): def __new__(mcs, name, bases, attrs):
""" """
+2 -9
View File
@@ -4,6 +4,8 @@ from abc import ABCMeta
class Proxy(object, metaclass=ABCMeta): class Proxy(object, metaclass=ABCMeta):
""" """
Base Proxy class as part of the Proxy design pattern. Base Proxy class as part of the Proxy design pattern.
External Proxy Pattern documentation: U{https://en.wikipedia.org/wiki/Proxy_pattern}
""" """
def __init__(self, subject): def __init__(self, subject):
""" """
@@ -26,12 +28,3 @@ class Proxy(object, metaclass=ABCMeta):
elif not callable(getattr(self._subject, attr, None)) or not callable(getattr(self, attr, None)): elif not callable(getattr(self._subject, attr, None)) or not callable(getattr(self, attr, None)):
raise AttributeError('Subject and Proxy must follow same interface') raise AttributeError('Subject and Proxy must follow same interface')