GoFの定義した23コのデザインパターンをPythonで実装します。
ただし、Pythonのビルトイン機能で実現できるパターンもあります。
その際は、ビルトイン機能の紹介に留めます。
Pythonらしい書き方(Pythonicな書き方)ができるものは古典的な実装とPythonicな実装の両方を紹介します。
パターンカテゴリ | パターン名 | コメント |
---|---|---|
生成に関するデザインパターン | Abstract Factory | |
Builder | ||
Factory Method | ||
Prototype | Pythonのライブラリ・ビルトイン有り | |
Singleton | Pythonのライブラリ・ビルトイン有り | |
構造に関するデザインパターン | Adapter | |
Bridge | Pythonicな書き方有り | |
Composite | ||
Decorator | Pythonビルトイン有り | |
Facade | ||
Flyweight | Python機能で代用 | |
Proxy | ||
ふるまいに関するデザインパターン | Chain of Responsibility | |
Command | ||
Interpreter | ||
Iterator | Pythonビルトイン有り | |
Mediator | ||
Memento | ||
Observer | ||
State | ||
Strategy | ||
Template Method | ||
Visitor | Pythonビルトイン有り |