added external design pattern documentation links to creational patterns.
This commit is contained in:
@@ -6,6 +6,8 @@ class Director(object, metaclass=ABCMeta):
|
|||||||
Abstract director class, responsible for using a builder to fully construct an object.
|
Abstract director class, responsible for using a builder to fully construct an object.
|
||||||
|
|
||||||
Part of the builder pattern.
|
Part of the builder pattern.
|
||||||
|
|
||||||
|
External Builder Pattern documentation: U{https://en.wikipedia.org/wiki/Builder_pattern}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -39,6 +41,8 @@ class Builder(object):
|
|||||||
Abstract builder class, responsible for constructing various pieces of an object.
|
Abstract builder class, responsible for constructing various pieces of an object.
|
||||||
|
|
||||||
Part of the builder pattern.
|
Part of the builder pattern.
|
||||||
|
|
||||||
|
External Builder Pattern documentation: U{https://en.wikipedia.org/wiki/Builder_pattern}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, constructed_object):
|
def __init__(self, constructed_object):
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ class Factory(object, metaclass=ABCMeta):
|
|||||||
Factory Interface.
|
Factory Interface.
|
||||||
|
|
||||||
All Factories should inherit this class and overwrite the create method.
|
All Factories should inherit this class and overwrite the create method.
|
||||||
"""
|
|
||||||
|
|
||||||
|
External Factory Pattern documentation: U{https://en.wikipedia.org/wiki/Factory_method_pattern}
|
||||||
|
"""
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def create(self, **kwargs):
|
def create(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
@@ -23,8 +24,9 @@ class Factory(object, metaclass=ABCMeta):
|
|||||||
class AbstractFactory(Factory):
|
class AbstractFactory(Factory):
|
||||||
"""
|
"""
|
||||||
Abstract Factory Class.
|
Abstract Factory Class.
|
||||||
"""
|
|
||||||
|
|
||||||
|
External Abstract Factory Pattern documentation: U{https://en.wikipedia.org/wiki/Abstract_factory_pattern}
|
||||||
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""
|
"""
|
||||||
Initialize the abstract factory.
|
Initialize the abstract factory.
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ from .singleton import Singleton
|
|||||||
class Reusable(object):
|
class Reusable(object):
|
||||||
"""
|
"""
|
||||||
An abstract reusable class.
|
An abstract reusable class.
|
||||||
"""
|
|
||||||
|
|
||||||
|
External Object Pool Pattern documentation: U{https://en.wikipedia.org/wiki/Object_pool_pattern}
|
||||||
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""
|
"""
|
||||||
Initialize a new Reusable instance.
|
Initialize a new Reusable instance.
|
||||||
@@ -24,8 +25,9 @@ class Reusable(object):
|
|||||||
class Pool(object, metaclass=Singleton):
|
class Pool(object, metaclass=Singleton):
|
||||||
"""
|
"""
|
||||||
An Object Pool design pattern implementation.
|
An Object Pool design pattern implementation.
|
||||||
"""
|
|
||||||
|
|
||||||
|
External Object Pool Pattern documentation: U{https://en.wikipedia.org/wiki/Object_pool_pattern}
|
||||||
|
"""
|
||||||
def __init__(self, reusable_class, *args, **kwargs):
|
def __init__(self, reusable_class, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Initialize a new object pool instance.
|
Initialize a new object pool instance.
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ from types import MethodType
|
|||||||
class Prototype(object):
|
class Prototype(object):
|
||||||
"""
|
"""
|
||||||
Prototype design pattern abstract class.
|
Prototype design pattern abstract class.
|
||||||
"""
|
|
||||||
|
|
||||||
|
External Prototype Pattern documentation: U{https://en.wikipedia.org/wiki/Prototype_pattern}
|
||||||
|
"""
|
||||||
def prototype(self, **attributes):
|
def prototype(self, **attributes):
|
||||||
"""
|
"""
|
||||||
Copy the prototype this object and optionally update attributes.
|
Copy the prototype this object and optionally update attributes.
|
||||||
@@ -22,4 +23,3 @@ class Prototype(object):
|
|||||||
setattr(obj, attribute, attributes[attribute])
|
setattr(obj, attribute, attributes[attribute])
|
||||||
|
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ class Singleton(type):
|
|||||||
Singleton Metaclass.
|
Singleton Metaclass.
|
||||||
|
|
||||||
Enforces any object using this metaclass to only create a single instance.
|
Enforces any object using this metaclass to only create a single instance.
|
||||||
|
|
||||||
|
External Singleton Pattern documentation: U{https://en.wikipedia.org/wiki/Singleton_pattern}
|
||||||
"""
|
"""
|
||||||
__instance = None
|
__instance = None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user