Giter VIP home page Giter VIP logo

go-patterns's Introduction

Golang设计模式**

  • 前言

    • 一切设计模式都是灵活应用struct的组合模式,以及go隐形继承接口的特性
    • go中的interface就是一些方法装饰, 而struct并不依赖于接口
  • 设计模式类型

创建模式

结构模式

  • 装饰模式(Decorator Pattern)
    • 装饰模式使用对象组合的方式动态改变或增加对象行为, 在原对象的基础上增加功能
      
  • 代理模式(Proxy Pattern)
    • 代理模式用于延迟处理操作或者在进行实际操作前后对真实对象进行其它处理。
      
  • 适配器模式(Adapter Pattern)
    • 将一个类的接口转换成客户希望的另外一个接口。适配器模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作
      
  • 组合模式(Composite)
    • 组合模式有助于表达数据结构, 将对象组合成树形结构以表示"部分-整体"的层次结构, 常用于树状的结构
      
  • 享元模式(Flyweight Pattern)
    • 把多个实例对象共同需要的数据,独立出一个享元,从而减少对象数量和节省内存
      
  • 外观模式(Facade Pattern)
    • 外观模式在客户端和现有系统之间加入一个外观对象, 为子系统提供一个统一的接入接口, 类似与委托
      
  • 桥接模式(Bridge Pattern)
    • 桥接模式分离抽象部分和实现部分,使得两部分可以独立扩展
      

行为模式

  • 观察者模式(Observer)
    • 定义对象间的一种一对多的依赖关系,以便当一个对象的状态发生改变时,所有依赖于它的对象都得到通知并自动刷新
      
  • 策略模式(Strategy)
    • 定义一系列算法,让这些算法在运行时可以互换,使得分离算法,符合开闭原则
      
  • 状态模式(State Pattern)
    • 用于系统中复杂对象的状态转换以及不同状态下行为的封装问题
      
  • 访问者模式(Visitor Pattern)
    • 访问者模式是将对象的数据和操作分离
      
  • 模板方法模式(Template Method Pattern)
    • 模版方法使用匿名组合的继承机制, 将通用的方法和属性放在父类中, 具体的实现放在子类中延迟执行
      
  • [备忘录模式(Memento Pattern)]
  • [中介模式(Mediator Pattern)]
  • 迭代器模式(Iterator Pattern)
    • 可以配合访问者模式,将不同的数据结构,使用迭代器遍历
      
  • [解释器模式(Interpreter Pattern)]
  • [命令模式(Command Pattern)]
  • [职责链模式(Chain of Responsibility)]

同步模式(synchronization patterns)

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.