【设计模式】python设计模式汇总

python以其独特的语言风格与思想被大家熟知(如下python之禅大家都熟知),本系列主要通过代码解读python常用的设计模式。

>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

一、创建型模式:

二、结构型模式:

  • 适配器模式:
  • 修饰器模式:
  • 外观模式:
  • 享元模式:
  • 模型-视图-控制器模式:
  • 代理模式:

三、行为型模式:

  • 责任链模式:
  • 命令模式:
  • 解释器模式:
  • 观察者模式:
  • 状态模式:
  • 策略模式:
  • 模板模式:
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 设计模式汇总 一、基础知识 1. 设计模式概述 定义:设计模式(Design Pattern)是一套被反复使用、多...
    MinoyJet阅读 9,423评论 1 15
  • 接触前端两三个月的时候,那时候只是听说设计模式很重要,然后我就去读了一本设计模式的书,读了一部分,也不知道这些设计...
    艰苦奋斗的侯小憨阅读 8,266评论 2 39
  • 前言 GoF的23种设计模式,包括创建型、结构型和行为型,其涵盖了面向对象思想的精髓以及诸多细节。本文结合《设计模...
    尤汐Yogy阅读 9,865评论 0 38
  • 设计模式问答(一) 什么是设计模式?您能说出工厂模式、抽象工厂模式、创建者模式、原型模式、原型模式的潜复制及深复制...
    程序猿Timothy阅读 4,166评论 0 3
  • 纯粹是个人学习总结,如有不对的地方请吐槽。 设计模式参考地址:http://www.cnblogs.com/mao...
    junwu_123阅读 3,996评论 0 0

友情链接更多精彩内容