Coder Social home page Coder Social logo

golang-design-pattern's Introduction

Goland 设计模式

Build Status codecov Action Status

设计模式 Golang实现-《研磨设计模式》读书笔记
Go 语言设计模式的实例代码

  • 创建型模式

    • 01.简单工厂模式 (Simple Factory) NewXXX初始化相关类
    • 02.工厂方法模式 (Factory Method) 使子类的方式延迟生成对象到子类中实现
    • 03.抽象工厂模式 (Abstract Factory) 超级工厂为其它工厂的工厂,又称中心工厂
    • 04.创建者模式 (Builder) builder一步步创建最终的对象
    • 05.原型模式 (Prototype) 创建当前对象的克隆,减少开销
    • 06.单例模式 (Singleton) 确保只有单个对象被创建.
  • 结构型模式

    • 01.外观模式 (Facade) 隐藏系统复杂性,无需关心底层具体实现,向外提供统一的接口,
    • 02.适配器模式 (Adapter)
    • 03.代理模式 (Proxy)
    • 04.组合模式 (Composite)
    • 05.享元模式 (Flyweight) 剥离不发生改变且多对象可共享的重复数据,独立出一个享元.
    • 06.装饰模式 (Decorator) 包装原有的类,保持原有类的完整性前提下,提供额外的功能.
    • 07.桥接模式 (Bridge)
  • 行为型模式

    • 01.中介者模式 (Mediator)
    • 02.观察者模式 (Observer) 一对多关系,当一个对象被修改,则会自动通知依赖它的对象
    • 03.命令模式 (Command)
    • 04.迭代器模式 (Iterator)
    • 05.模板方法模式 (Template Method)
    • 06.策略模式 (Strategy)
    • 07.状态模式 (State)
    • 08.备忘录模式 (Memento)
    • 09.解释器模式 (Interpreter)
    • 10.职责链模式 (Chain of Responsibility)
    • 11.访问者模式 (Visitor)

六大基本原则

  • 单一职责原则: 指出每一个模块或类应当拥有的一个部分责任的功能由提供软件,而责任应完全封装在类
  • 开闭原则: 说对扩展开放,对修改关闭
  • 里式替换原则: 子类可以实现父类的抽象方法,但是不能覆盖父类的非抽象方法在我们做系统设计时,经常会设计接口或抽象类,然后由子类来实现抽象方法
  • 接口隔离原则: 接口应该尽量细化,一个接口对应一个功能模块,同时接口里面的方法应该尽可能的少,使接口更加轻便灵活。
  • 依赖反转原则: 是指一种特定的解耦(传统的依赖关系创建在高层次上,而具体的策略设置则应用在低层次的模块上)形式,使得高层次的模块不依赖于低层次的模块的实现细节,依赖关系被颠倒(反转),从而使得低层次模块依赖于高层次模块的需求抽象。
  • 迪米特法则: 一个实体应当尽量少的与其他实体之间发生相互作用,使得系统功能模块相对独立

golang-design-pattern's People

Contributors

dhlin avatar senghoo avatar thinkgos avatar xpzouying avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

355911097

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.