- 不要为了模式而模式,一般情况下代码简洁才是最重要的
- 在新需求可能彻底推翻旧需求的情况下,尽量不要使用设计模式(设计模式大部分情况下会让代码变得复杂)
- 先理解每个模式的动机,再谈设计
- go 语言的设计模式不应该止步于 GoF 的 23 种设计模式,函数是一等公民的语言应有更多的设计可深究
Pattern | Status |
---|---|
Factory Method | ✔ |
Abstract Factory | ✔ |
Builder | ✔ |
Prototype | ✔ |
Singleton | ✔ |
Pattern | Status |
---|---|
Facade | ✔ |
Adapter | ✔ |
Proxy | ✔ |
Composite | ✔ |
Flyweight | ✔ |
Decorator | ✔ |
Bridge | ✔ |
Pattern | Status |
---|---|
Mediator | ✘ |
Observer | ✘ |
Command | ✘ |
Iterator | ✘ |
Template Method | ✘ |
Strategy | ✘ |
State | ✘ |
Interpreter | ✘ |
Memento | ✘ |
Chain of Responsibility | ✘ |
Visitor | ✘ |