Giter Site home page Giter Site logo

patternguide's Introduction

设计模式,是在程序员成长之路的必学经典,因为这是前人所总结出来的,最佳的实践方法,学会设计模式,提高代码质量,而不是让写出来的代码不堪入目。本项目是我在学习中总结的笔记,以及代码实践。

设计原则

注意,开发时应尽量遵循一下原则,特殊情况特殊对待

1、多用组合(接口),少用继承

2、封装变化,即找出程序中会变化的方面,然后将其和固定不变方面相分离

3、面向接口编程,而非针对实现编程

4、为了交互对象之间的松耦合设计而努力(优先级很高)

5、类应该可对扩展开放,对修改关闭(优先级最高)

6、依赖抽象,不要依赖具体类

7、依赖倒置原则:底层模块依赖高层模块,而非高层模块依赖低层模块,移除低层模块后高层模块仍能正常工作,只是少了部分功能,即高层模块调用低层模块,低层模块禁止调用高层模块

8、一个类应该只有一个引起变化的原因

9、高内聚,低耦合

10、知少原则,一般情况下,类类之间关系越少越好,就一个类只与一两个类来往

目录

1 . 策略模式(Strategy Pattern)

2 . 观察者模式(Observer Pattern)

3 . 装饰者模式(Decorator Pattern)

4 . 工厂模式(Factory Pattern)

5 . 抽象工厂模式(Abstract Factory Pattern),请先阅读工厂模式

6 . 单例模式(Singleton Pattern)

7 . 适配器模式(Adapter Pattern)

8 . 迭代器模式(Iterator Pattern)

9 . 命令模式(Command Pattern)

10 . 组合模式(Composite Pattern)

11 . 外观模式(Facade Pattern)

12 . 模板模式(Template Pattern)

13 . 状态模式(State Pattern)

14 . 代理模式(Proxy Pattern)

15 . MVC 模式代表 Model-View-Controller(模型-视图-控制器) 模式

patternguide's People

Contributors

baryleo avatar

Stargazers

 avatar

Watchers

James Cloos avatar  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.