收集用Pyhton写的设计模式和风格.
当有一个新的成品时, 更新这个文件并执行append_output.sh
(举个栗子: ./append_output.sh borg.py), 以保证底部的输入结果是最新的.
已有的模式:
| 模式 | 说明 |
|---|---|
| 三层架构 | 数据<->业务逻辑<->描述 分离 (严格的关系) |
| mvc | 模型<->视图<->控制器 (非严格的关系) |
| borg | 在实例中共享状态的一种单例模式(id不一样, state一样) |
| 抽象工厂模式 | 用一个通用的方法, 根据特定的工厂类来创建一个类的实例 |
| 工厂模式 | 根据专门的函数或者方法, 创建一个类的实例 |
| 原型 | 用一个工厂类, 通过复制原型, 得到一个新的实例(如果实例存在的话) |
| adapter | adapt one interface to another using a whitelist |
| bridge | a client-provider middleman to soften interface changes |
| builder | call many little discrete methods rather than having a huge number of constructor parameters |
| catalog | general methods will call different specialized methods based on construction parameter |
| chain | apply a chain of successive handlers to try and process the data |
| command | bundle a command and arguments to call later |
| composite | encapsulate and provide access to a number of different objects |
| decorator | wrap functionality with other functionality in order to affect outputs |
| facade | use one class as an API to a number of others |
| flyweight | transparently reuse existing instances of objects with similar/identical state |
| graph_search | (graphing algorithms, not design patterns) |
| mediator | an object that knows how to connect other objects and act as a proxy |
| memento | generate an opaque token that can be used to go back to a previous state |
| observer | provide a callback for notification of events/changes to data |
| pool | preinstantiate and maintain a group of instances of the same type |
| proxy | an object funnels operations to something else |
| publish_subscribe | a source syndicates events/data to 0+ registered listeners |
| state | logic is org'd into a discrete number of potential states and the next state that can be transitioned to |
| strategy | selectable operations over the same data |
| template | an object imposes a structure but takes pluggable components |
| visitor | invoke a callback for all items of a collection |
| chaining_method | continue callback next object method |