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

View File

@@ -1,6 +1,8 @@
class Adapter(object):
"""
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):
"""
@@ -28,4 +30,3 @@ class Adapter(object):
Get the adaptee's __dict__
"""
return self.__adaptee.__dict__

View File

@@ -4,6 +4,8 @@ from abc import ABCMeta
class Bridge(object, metaclass=ABCMeta):
"""
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):
"""

View File

@@ -1,6 +1,8 @@
class Composite(object):
"""
Composite class as part of the Composite pattern.
External Composite Pattern documentation: U{https://en.wikipedia.org/wiki/Composite_pattern}
"""
def __init__(self, interface):
"""

View File

@@ -5,6 +5,8 @@ from abc import ABCMeta, abstractmethod
class Decorator(object, metaclass=ABCMeta):
"""
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):
"""
@@ -23,6 +25,8 @@ class Decorator(object, metaclass=ABCMeta):
class DecoratorSimple(Decorator, metaclass=ABCMeta):
"""
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):
"""
@@ -36,6 +40,8 @@ class DecoratorSimple(Decorator, metaclass=ABCMeta):
class DecoratorComplex(Decorator, metaclass=ABCMeta):
"""
A Base Decorator class for decorators with arguments.
External Decorator Pattern documentation: U{https://en.wikipedia.org/wiki/Decorator_pattern}
"""
@abstractmethod
def __init__(self, *args, **kwargs):
@@ -63,6 +69,8 @@ class DecoratorComplex(Decorator, metaclass=ABCMeta):
class CallWrapper(DecoratorSimple):
"""
A Decorator for wrapping DecoratorComplex __call__ methods.
External Decorator Pattern documentation: U{https://en.wikipedia.org/wiki/Decorator_pattern}
"""
def __call__(self, instance, func):
"""

View File

@@ -1,6 +1,8 @@
class FlyweightMeta(type):
"""
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):
"""

View File

@@ -4,6 +4,8 @@ from abc import ABCMeta
class Proxy(object, metaclass=ABCMeta):
"""
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):
"""
@@ -26,12 +28,3 @@ class Proxy(object, metaclass=ABCMeta):
elif not callable(getattr(self._subject, attr, None)) or not callable(getattr(self, attr, None)):
raise AttributeError('Subject and Proxy must follow same interface')