Git Product home page Git Product logo

study's Introduction

###设计模式与原则

背景

编程初学者往往碰到问题时直觉地用计算机能够理解的逻辑来描述和表达待解决的问题及具体的求解过程。 这其实是用计算机的方式去思考,本身没有错,但这样的思维却使得我们的程序只为满足实现当前的需求, 程序不容易维护,不容易扩展,更不容易复用。从而达不到高质量代码的要求。

解决方法:使用面向对象的分析设计编程**,通过封装、继承、多态把程序的耦合度降低,用设计模式 使得程序更加灵活,容易修改,并且易于复用。

用于生成对象的模式

  • 单例(Singleton)模式:生成一个且只生成一个对象实例的特殊类。
  • 工厂方法(Factory Method)模式:构建创建者类的继承层级。
  • 抽象工厂(Abstract Factory)模式:功能相关产品的创建。
  • 原型(Prototype)模式:使用克隆来生成对象。

用于组织对象和类的模式

  • 组合(Composite)模式:将一组对象组合为可像单个对象一样被适用的结构。
  • 装饰(Decorator)模式:通过在运行时合并对象来扩展功能的一种灵活机制。
  • 外观(Facade)模式:为复杂或多变的系统创建一个简单的接口。

面向任务的模式

  • 解释器(Interpreter)模式:构造一个可以用于创建脚本化应用的迷你语言解释器。
  • 策略(Strategy)模式:在系统中定义算法并以它们自己的类型封装。
  • 观察者(Observer)模式:创建依赖关系,当有系统事件发生时通知观察者对象。
  • 访问者(Visitor)模式:在对象树的所有节点上应用操作。
  • 命令(Command)模式:创建可被保存和传送的命令对象。

study's People

Contributors

aimococo 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.