82

GitHub - sevenelevenlee/go-patterns: Golang 设计模式

 4 years ago
source link: https://github.com/sevenelevenlee/go-patterns
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

README.md

Golang设计模式思想

  • 前言

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

创建模式

结构模式

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

行为模式

同步模式(synchronization patterns)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK