接口隔离原则

接口隔离原则英語:, 缩写:ISP)指明客户(client)不應被迫使用對其而言無用的方法或功能。[1]接口隔离原则(ISP)拆分非常庞大臃肿的接口成为更小的和更具体的接口,这样客户将会只需要知道他们感兴趣的方法。这种缩小的接口也被称为角色接口(role interfaces)。[2]接口隔离原则(ISP)的目的是系统解开耦合,从而容易重构,更改和重新部署。接口隔离原则是在SOLID (面向对象设计)中五个面向对象设计(OOD)的原则之一,类似于在GRASP (面向对象设计)中的高内聚性[3]

在面向对象设计中的重要性

面向对象设计中,接口(interface)提供了便于代码在概念上解释的抽象层,并建立了避免依赖的一个屏障。

参看

参考文献

  1. Martin, Robert (2002). Agile Software Development: Principles, Patterns and Practices. Pearson Education.
  2. Role Interface
  3. . [2014-02-22]. (原始内容存档于2010-08-20).

外部链接

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.