文件名称:( [Python.in.Practice(2013.8)].Mark.Summerfield.文字版(英语)
文件大小:2.33MB
文件格式:PDF
更新时间:2017-07-28 12:32:58
[Python Practice Mark Summerfield
Contents Foreword .......................................................... xiii Introduction ...................................................... 1 Acknowledgments................................................ 3 Chapter 1. Creational Design Patterns in Python................ 5 1.1. Abstract Factory Pattern .................................... 5 1.1.1. A Classic Abstract Factory .............................. 6 1.1.2. A More Pythonic Abstract Factory........................ 9 1.2. Builder Pattern.............................................. 11 1.3. Factory Method Pattern ...................................... 17 1.4. Prototype Pattern............................................ 24 1.5. Singleton Pattern ............................................ 26 Chapter 2. Structural Design Patterns in Python................ 29 2.1. Adapter Pattern.............................................. 29 2.2. Bridge Pattern .............................................. 34 2.3. Composite Pattern .......................................... 40 2.3.1. A Classic Composite/Noncomposite Hierarchy ............ 41 2.3.2. A Single Class for (Non)composites ...................... 45 2.4. Decorator Pattern............................................ 48 2.4.1. Function and Method Decorators ........................ 48 2.4.2. Class Decorators........................................ 54 2.4.2.1. Using a Class Decorator to Add Properties .......... 57 2.4.2.2. Using a Class Decorator Instead of Subclassing...... 58 2.5. Façade Pattern .............................................. 59 2.6. Flyweight Pattern............................................ 64 2.7. Proxy Pattern................................................ 67 Chapter 3. Behavioral Design Patterns in Python................ 73 3.1. Chain of Responsibility Pattern .............................. 74 3.1.1. A Conventional Chain .................................. 74 3.1.2. A Coroutine-Based Chain................................ 76 3.2. Command Pattern............................................ 79