设计原则 [英] Design Principles
本文介绍了设计原则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
面向对象类设计原理(SOLID原则)
- SRP:单一责任
原则课程应该有一个
和只有一个,理由更改。 - OCP:开放封闭原则您
应该能够扩展一个类
行为而不修改它。 - LSP:Liskov替换
原则派生类必须是
可替代基础
类。 - ISP:界面隔离
原则使客户特定的细粒度
接口 - DIP:依赖性
反转原则取决于
抽象,而不是实体。
$ b $来源: http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
What principles do you generally follow when doing class design?
解决方案
Principles Of Object Oriented Class Design (the "SOLID" principles)
- SRP: The Single Responsibility Principle A class should have one, and only one, reason to change.
- OCP: The Open Closed Principle You should be able to extend a classes behavior, without modifying it.
- LSP: The Liskov Substitution Principle Derived classes must be substitutable for their base classes.
- ISP: The Interface Segregation Principle Make fine grained interfaces that are client specific.
- DIP: The Dependency Inversion Principle Depend on abstractions, not on concretions.
Source: http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
这篇关于设计原则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文