《Head First 设计模式》 - 设计原则总结
- 将变化的部分封装起来(Encapsulate what varies)
- 组合优于继承(Favor composition over inheritance)
- 面向接口编程而非实现(Program to interfaces, not implementations.)
- 减少需要交互的类之间的耦合(Strive for loosely coupled designs between objects that interact)
- 对拓展开放,对修改关闭(Classes should be open for extension but closed for modification.)
- 依赖于抽象而非具体的类( Depend on abstraction. Do not depend on concrete classes)
- 暴露最少的信息给其他类(最少知识原则)(Talk only to your immediate friends)
- 高层有对底层的管理,而底层不需要关心高层何时会调用自己(好莱坞原则)(Don’t call us ,we’ll call you)
- 一个类应该有且只有一个被改变的理由(A class should have only one reason to change)
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 三叔胡言乱语的地方!
评论