Code Monkey home page Code Monkey logo

pythondesignmodel's Introduction

查看github 上的jpynb文件

https://nbviewer.jupyter.org/github/a524631266/当前网页文件地址

pythondesignmodel

根据python的设计模式书籍做的一系列设计模式练习
  • 作者一再强调:新手最好不要先接触设计模式,而是在写代码的过程中在解决问题的情况下 先尝试着用最简单的编码方式来解决,当无法解决的时候,就需要通过设计模式统一口径, 方才有用
  • 同时设计模式的设计,针对同一个项目,不同经验的开发者会使用不同的设计模式,所以, 设计模式更多的是一种抽象的组织框架方式,而不关注代码细节

1. 创建型模式

顾明思义,创建型是根对象的生产有关系的,所以在python设计模式书中描述的大体有三种
通俗理解为__init__设计模式
- a 生产者(factory)模式
    ```
    该模式是产生于,python基于__init__实例化生产对象的基础上,为了跟好地跟踪定位,解决代码的复杂维护性而设计出来的,主要是通过一个函数(工厂)生产对象.
    ```
    1. 工厂函数 ,创建一个对象
    2. 抽象工厂, 通过抽象工厂函数统一创建多个对象
- b 建造者(builder)模式
- c 原型(prototype)模式
    ```
        通过 浅拷贝与深拷贝(clone)技术创建对象
        其中 深拷贝对象的属性不互相干扰
        而浅拷贝对象是会互相干扰的(引用))
    ```

2. 结构型模式

3. 行为型模式

pythondesignmodel's People

Contributors

a524631266 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.