|
1 | 1 | python-patterns |
2 | 2 | =============== |
3 | 3 |
|
4 | | -A collection of design patterns implemented (by other people) in python |
| 4 | +A collection of design patterns and idioms in Python. |
| 5 | + |
| 6 | +When an implementation is added or modified, be sure to update this file and |
| 7 | +rerun `append_output.sh` (eg. ./append_output.sh borg.py) to keep the output |
| 8 | +comments at the bottom up to date. |
5 | 9 |
|
6 | 10 | Current Patterns: |
7 | 11 |
|
8 | | -* 3-tier |
9 | | -* composite |
10 | | -* mvc |
11 | | -* decorator |
12 | | -* null |
13 | | -* facade |
14 | | -* observer |
15 | | -* abstract_factory |
16 | | -* factory_method |
17 | | -* pool |
18 | | -* adapter |
19 | | -* flyweight |
20 | | -* prototype |
21 | | -* borg |
22 | | -* proxy |
23 | | -* bridge |
24 | | -* graph_search |
25 | | -* state |
26 | | -* builder |
27 | | -* iterator |
28 | | -* strategy |
29 | | -* chain |
30 | | -* mediator |
31 | | -* template |
32 | | -* command |
33 | | -* memento |
34 | | -* visitor |
| 12 | +| Pattern | Description | |
| 13 | +|:-------:| ----------- | |
| 14 | +| [3-tier](3-tier.py) | data<->business logic<->presentation separation (strict relationships) | |
| 15 | +| [abstract_factory](abstract_factory.py) | use a generic function with specific factories | |
| 16 | +| [adapter](adapter.py) | adapt one interface to another using a whitelist | |
| 17 | +| [borg](borg.py) | a singleton with shared-state among instances | |
| 18 | +| [bridge](bridge.py) | a client-provider middleman to soften interface changes | |
| 19 | +| [builder](builder.py) | call many little discrete methods rather than having a huge number of constructor parameters | |
| 20 | +| [catalog](catalog.py) | general methods will call different specialized methods based on construction parameter | |
| 21 | +| [chain](chain.py) | apply a chain of successive handlers to try and process the data | |
| 22 | +| [command](command.py) | bundle a command and arguments to call later | |
| 23 | +| [composite](composite.py) | encapsulate and provide access to a number of different objects | |
| 24 | +| [decorator](decorator.py) | wrap functionality with other functionality in order to affect outputs | |
| 25 | +| [facade](facade.py) | use one class as an API to a number of others | |
| 26 | +| [factory_method](factory_method.py) | delegate a specialized function/method to create instances | |
| 27 | +| [flyweight](flyweight.py) | transparently reuse existing instances of objects with similar/identical state | |
| 28 | +| [graph_search](graph_search.py) | (graphing algorithms, not design patterns) | |
| 29 | +| [mediator](mediator.py) | an object that knows how to connect other objects and act as a proxy | |
| 30 | +| [memento](memento.py) | generate an opaque token that can be used to go back to a previous state | |
| 31 | +| [mvc](mvc.py) | model<->view<->controller (non-strict relationships) | |
| 32 | +| [observer](observer.py) | provide a callback for notification of events/changes to data | |
| 33 | +| [pool](pool.py) | preinstantiate and maintain a group of instances of the same type | |
| 34 | +| [prototype](prototype.py) | use a factory and clones of a prototype for new instances (if instantiation is expensive) | |
| 35 | +| [proxy](proxy.py) | an object funnels operations to something else | |
| 36 | +| [publish_subscribe](publish_subscribe.py) | a source syndicates events/data to 0+ registered listeners | |
| 37 | +| [state](state.py) | logic is org'd into a discrete number of potential states and the next state that can be transitioned to | |
| 38 | +| [strategy](strategy.py) | selectable operations over the same data | |
| 39 | +| [template](template.py) | an object imposes a structure but takes pluggable components | |
| 40 | +| [visitor](visitor.py) | invoke a callback for all items of a collection | |
| 41 | +| [chaining_method](chaining_method.py) | continue callback next object method | |
0 commit comments