|
| 1 | +# Python Patterns |
| 2 | + |
| 3 | +A collection of design patterns and idioms in Python. |
| 4 | + |
| 5 | +*** |
| 6 | + |
| 7 | +## Current Patterns |
| 8 | + |
| 9 | +__Creational Patterns__: |
| 10 | + |
| 11 | +| Pattern | Description | |
| 12 | +|:-------:| ----------- | |
| 13 | +| [Abstract Factory](patterns/creational/abstract_factory.py) | use a generic function with specific factories | |
| 14 | +| [Builder](patterns/creational/builder.py) | instead of using multiple constructors, builder receives parameters and returns constructed objects | |
| 15 | +| [Factory Method](patterns/creational/factory.py) | delegate a specialized function/method to create instances| |
| 16 | +| [Prototype](patterns/creational/prototype.py) | use a factory and clones of a prototype for new instances (if instantiation is expensive) | |
| 17 | +| [Singleton](patterns/creational/singleton.py) | Ensures that the class has only one instance, and provides a global access point to it. | |
| 18 | + |
| 19 | +__Structural Patterns__: |
| 20 | + |
| 21 | +| Pattern | Description | |
| 22 | +|:-------:| ----------- | |
| 23 | +| [Adapter](patterns/structural/adapter.py) | converts the interface of one class to the interface of another that clients expect. | |
| 24 | +| [Bridge](patterns/structural/bridge.py) | a client-provider middleman to soften interface changes | |
| 25 | +| [Composite](patterns/structural/composite.py) | lets clients treat individual objects and compositions uniformly | |
| 26 | +| [Decorator](patterns/structural/decorator.py) | wrap functionality with other functionality in order to affect outputs | |
| 27 | +| [Facade](patterns/structural/facade.py) | use one class as an API to a number of others | |
| 28 | +| [Flyweight](patterns/structural/flyweight.py) | transparently reuse existing instances of objects with similar/identical state | |
| 29 | +| [Proxy](patterns/structural/proxy.py) | an object funnels operations to something else | |
| 30 | + |
| 31 | +__Behavior Patterns__: |
| 32 | + |
| 33 | +| Pattern | Description | |
| 34 | +|:-------------------------------------------------------------------------:| ----------- | |
| 35 | +| [Blackboard](patterns/behavioral/blackboard.py) | architectural model, assemble different sub-system knowledge to build a solution, AI approach - non gang of four pattern. | |
| 36 | +| [Chain Of Responsibility](patterns/behavioral/chain_of_responsibility.py) | apply a chain of successive handlers to try and process the data. | |
| 37 | +| [Command](patterns/behavioral/command.py) | bundle a command and arguments to call later. | |
| 38 | +| [Interpreter](patterns/behavioral/interpreter.py) | a behavioral design pattern that solves a frequently encountered but subject to change problem. | |
| 39 | +| [Iterator](patterns/behavioral/iterator.py) | traverse a container and access the container's elements. | |
| 40 | +| [Mediator](patterns/behavioral/mediator.py) | an object that knows how to connect other objects and act as a proxy. | |
| 41 | +| [Memento](patterns/behavioral/memento.py) | generate an opaque token that can be used to go back to a previous state. | |
| 42 | +| [Observer](patterns/behavioral/observer.py) | provide a callback for notification of events/changes to data. | |
| 43 | +| [State](patterns/behavioral/state.py) | logic is organized into a discrete number of potential states and the next state that can be transitioned to. | |
| 44 | +| [Strategy](patterns/behavioral/strategy.py) | selectable operations over the same data. | |
| 45 | +| [Template Method](patterns/behavioral/template_method.py) |defines the basis of the algorithm and allows subclasses to override some of the steps in the algorithm, without changing its structure as a whole. | |
| 46 | +| [Visitor](patterns/behavioral/visitor.py) | invoke a callback for all items of a collection. | |
| 47 | + |
| 48 | +*** |
| 49 | + |
| 50 | +## Disclaimer of liability: |
| 51 | + |
| 52 | + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 53 | + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 54 | + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 55 | + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 56 | + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 57 | + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 58 | + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 59 | + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 60 | + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 61 | + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 62 | + |
| 63 | +*** |
| 64 | + |
| 65 | + # -------------------------------------------------------- |
| 66 | + # Licensed under the terms of the BSD 3-Clause License |
| 67 | + # (see LICENSE for details). |
| 68 | + # Copyright © 2018-2024, A.A Suvorov |
| 69 | + # All rights reserved. |
| 70 | + # -------------------------------------------------------- |
0 commit comments