接口隔离原则(Interface Segregation Principle)

接口隔离原则(Interface Segregation Principle)

Content #

Robert Martin 在 SOLID 原则中是这样定义它的: Clients should not be forced to depend upon interfaces that they do not use. 客户端不应该被强迫依赖它不需要的接口。其中的“客户端”,可以理解为接口的调用者或者使用者。

可以把“接口”理解为下面三种东西:

  1. 一组 API 接口集合( 把接口理解为一组API接口集合)
  2. 单个 API 接口或函数( 把接口理解为单个API接口或函数)
  3. OOP 中的接口概念( 把接口理解为OOP中的接口概念)

Viewpoints #

From #

18 | 理论四:接口隔离原则有哪三种应用?原则中的“接口”该如何理解?-设计模式之美-极客时间