removed proxy, bridge, template, and strategy patterns as they were too abstract to offer much use.
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
|
||||
class Strategy(object, metaclass=ABCMeta):
|
||||
"""
|
||||
An abstract Strategy class.
|
||||
All strategies should inherit this class.
|
||||
|
||||
External Strategy Pattern documentation: U{https://en.wikipedia.org/wiki/Strategy_pattern}
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def __call__(self, *args, **kwargs):
|
||||
"""
|
||||
Abstract method that must be overridden.
|
||||
The overridden method should execute the classes strategy.
|
||||
"""
|
||||
pass
|
||||
@@ -1,15 +0,0 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
|
||||
class Template(object, metaclass=ABCMeta):
|
||||
"""
|
||||
Abstract Template class as part of the Template design pattern.
|
||||
|
||||
External Template Design Pattern Documentation: U{https://en.wikipedia.org/wiki/Template_method_pattern}
|
||||
"""
|
||||
@abstractmethod
|
||||
def go(self):
|
||||
"""
|
||||
Abstract method to call the concrete templates methods.
|
||||
"""
|
||||
pass
|
||||
@@ -1,17 +0,0 @@
|
||||
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):
|
||||
"""
|
||||
Initialize a new Bridge instance.
|
||||
|
||||
@param implementor: The implementor that concrete classes should call upon to do some action.
|
||||
"""
|
||||
self.implementor = implementor
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
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):
|
||||
"""
|
||||
Initialize a new proxy instance.
|
||||
|
||||
@param subject: The real subject this proxy calls upon.
|
||||
"""
|
||||
self._subject = subject
|
||||
self._validate()
|
||||
|
||||
def _validate(self):
|
||||
"""
|
||||
Validate that the subject and this proxy follow the same interface.
|
||||
|
||||
@raise AttributeError: If the subject and this proxy do not follow the same interface.
|
||||
"""
|
||||
for attr in dir(self._subject):
|
||||
if attr.startswith('_') or attr.startswith('__'):
|
||||
continue
|
||||
|
||||
elif not callable(getattr(self._subject, attr, None)) or not callable(getattr(self, attr, None)):
|
||||
raise AttributeError('Subject and Proxy must follow same interface')
|
||||
Reference in New Issue
Block a user