Loving Coding & Visual Design
面向对象编程的SOLID原则
SOLID原则(单一职责,开放封闭,里氏替换,接口隔离和依赖反转)是面向对象编程和设计的五项基本原则。目标是创建一个系统,很容易维护和扩展。
S代表SRP:
Single responsibility principle 单一职责原则
a class should have only a single responsibility. 一个类应该只有一个单一的职则
O代表OCP
Open/closed principle 开放封闭原则
“software entities … should be open for extension, but closed for modification”. 软件个体应该对扩展开放,而禁止对内部的修改
L代表LSP
Liskov substitution principle 里氏替换原则
“objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program”. 程序对象应该可以被它的子类实例替换,而不失正确性
I代表ISP
Interface segregation principle 接口隔离原则
“many client-specific interfaces are better than one general-purpose interface.” 多个专门的接口优于多合一的接口
D代表DIP
Dependency inversion principle 依赖反转原则
one should “Depend upon Abstractions. Do not depend upon concretions.” 不同级别的模块之间的依赖应该在于抽象,而不是具体
Link: http://en.wikipedia.org/wiki/Solid_%28object-oriented_design%29
S代表SRP:
Single responsibility principle 单一职责原则
a class should have only a single responsibility. 一个类应该只有一个单一的职则
O代表OCP
Open/closed principle 开放封闭原则
“software entities … should be open for extension, but closed for modification”. 软件个体应该对扩展开放,而禁止对内部的修改
L代表LSP
Liskov substitution principle 里氏替换原则
“objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program”. 程序对象应该可以被它的子类实例替换,而不失正确性
I代表ISP
Interface segregation principle 接口隔离原则
“many client-specific interfaces are better than one general-purpose interface.” 多个专门的接口优于多合一的接口
D代表DIP
Dependency inversion principle 依赖反转原则
one should “Depend upon Abstractions. Do not depend upon concretions.” 不同级别的模块之间的依赖应该在于抽象,而不是具体
Link: http://en.wikipedia.org/wiki/Solid_%28object-oriented_design%29
最 近 文 章
- 无法安装微信 请释放一些存储空间并重试 - Sun, 12 Jan 2014 08:47:55 +0000
- 天路之旅-川藏线走尼泊尔 - Mon, 06 Jan 2014 13:50:10 +0000
- Godaday主机之间快速迁移的办法 - Sun, 24 Nov 2013 10:04:43 +0000
- 乐山坐汽车去成都宜家的两种方式 - Thu, 21 Nov 2013 10:01:23 +0000
- 初次徒步川藏线 - Sat, 09 Nov 2013 15:50:10 +0000
- 测试PHP on GAE - Tue, 24 Sep 2013 13:43:03 +0000
- 终于把Chrome Extension: GDLink升级到manifest_version 2 - Thu, 05 Sep 2013 23:21:10 +0000
- Twitter REST API升级到1.1 - Wed, 04 Sep 2013 15:24:51 +0000
- 网页制作带给我的那份宁静 - Tue, 27 Aug 2013 16:14:48 +0000
- mysql error: Got error 28 from storage engine - Fri, 14 Jun 2013 11:16:59 +0000