码迷,mamicode.com
首页 > 其他好文 > 详细

Principles of OO Design

时间:2015-07-21 22:10:07      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:

OO的一些基本特性

  • 封装(Encapsulation)
  • 继承(Inheritance)
  • 多态(Polymorphism)
  • 内聚(cohesion)
  • 耦合(coupling)

 

进行OO设计的5个原则 (SOLID)

  • 单一职责原则(SRP - Single Responsibility Principle)
    A CLASS SHOULD HAVE ONLY ONE REASON TO CHANGE.
  • 开放封闭原则(OCP - Open-Closed Principle)
    You should be able to extend a classes behavior, without modifying it.
  • 里氏替换原则(LSP - Liskov Substitution Principle)
    Derived classes must be substitutable for their base classes.
  • 接口隔离原则(ISP - Interface Segregation Principle)
    Make fine grained interfaces that are client specific.
  • 依赖倒置原则(DIP - Dependency Inversion Principle)
    Depend on abstractions, not on concretions.

 

SRP

"There should never be more than one reason for a class to change." — Robert C. Martin

 

Principles of OO Design

标签:

原文地址:http://www.cnblogs.com/haibinyuan/p/4665668.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!