Python Design Patterns 简明教程
Python Design Patterns - Introduction
设计模式用于表示开发人员创建软件或 Web 应用程序所用的模式。这些模式基于需求分析进行选择。模式描述了问题的解决方案、何时何地应用解决方案以及实现的后果。
Design patterns are used to represent the pattern used by developers to create software or web application. These patterns are selected based on the requirement analysis. The patterns describe the solution to the problem, when and where to apply the solution and the consequences of the implementation.
Structure of a design pattern
设计模式的文档以一种更侧重于所用技术及其方式的方式来维护。下图解释了设计模式文档的基本结构。
The documentation of design pattern is maintained in a way that focuses more on the technology that is used and in what ways. The following diagram explains the basic structure of design pattern documentation.

Why Python?
Python 是一种开源脚本语言。它拥有支持各种设计模式的库。Python 的语法易于理解并使用英语关键字。
Python is an open source scripting language. It has libraries that support a variety of design patterns. The syntax of python is easy to understand and uses English keywords.
Python 提供对下面列出的设计模式的支持。这些设计模式将在本教程中用到 -
Python provides support for the list of design patterns that are mentioned below. These design patterns will be used throughout this tutorial −
-
Model View Controller Pattern
-
Singleton pattern
-
Factory pattern
-
Builder Pattern
-
Prototype Pattern
-
Facade Pattern
-
Command Pattern
-
Adapter Pattern
-
Prototype Pattern
-
Decorator Pattern
-
Proxy Pattern
-
Chain of Responsibility Pattern
-
Observer Pattern
-
State Pattern
-
Strategy Pattern
-
Template Pattern
-
Flyweight Pattern
-
Abstract Factory Pattern
-
Object Oriented Pattern
Benefits of using design pattern
以下是设计模式的不同优点 -
Following are the different benefits of design pattern −
-
Patterns provide developer a selection of tried and tested solutions for the specified problems.
-
All design patterns are language neutral.
-
Patterns help to achieve communication and maintain well documentation.
-
It includes a record of accomplishment to reduce any technical risk to the project.
-
Design patterns are highly flexible to use and easy to understand.