Ebook Learning Python Design Patterns

Learning Python Design Patterns
Learning Python Design Patterns



Nhà xuất bản Packt Publishing
Tác giả Gennadiy Zlobin
Số trang 100
Ngày xuất bản 2013
File PDF

Chapter 1: Model-View-Controller 7
Model – the knowledge of the application 8
View – the appearance of knowledge 8
Controller – the glue between the model and view 9
Benefts of using the MVC 10
Implementation in Python 10
Summary 16

Chapter 2: Creating Only One Object with the Singleton Pattern 17
A module-level singleton 18
A classic singleton 19
The borg singleton 20
Implementation in Python 21
Summary 26

Chapter 3: Building Factories to Create Objects 27
The Factory Method 29
Advantages of using the Factory Method pattern 30
The Factory Method implementation 30
Abstract Factory 35
Advantages of using the Abstract Factory pattern 36
Abstract Factory implementation 37
Abstract Factory versus Factory Method 40
Summary 41

Chapter 4: The Facade Design Pattern 43
The Facade design pattern 43
Problems solved by the Facade pattern 45
Advantages of the Facade design pattern 45
Facades in Python’s standard library 45
Implementation in Python 47
Summary 51

Chapter 5: Facilitating Object Communication with Proxy
and Observer Patterns 53
Proxy design pattern 54
Problems solved by the Proxy pattern 54
The use of the Proxy pattern 55
Advantages and disadvantages of the Proxy design pattern 55
Implementation in Python 55
Observer design pattern 59
Problems solved by the Observer pattern 60
Use of the Observer pattern 61
Advantages of the Observer pattern 61
Implementation in Python 61
Summary 65

Chapter 6: Encapsulating Calls with the Command Pattern 67
Command Pattern terminology 68
Use cases of the Command design pattern 69
Advantages and disadvantages of the Command design pattern 69
Implementation in Python 70
Summary 75

Chapter 7: Redefning Algorithms with the Template Method 77
The Template Method design pattern 77
The benefts of the Template Method design pattern 78
Using hooks 79
Implementation in Python 79
Summary 85
Index 87

Be the first to comment

Leave a Reply

Your email address will not be published.