接口隔离原则(ISP--Interface Segregation Principle)
2014-08-28 22:19
169 查看
接口隔离原则(ISP--Interface Segregation Principle)
定义:
客户端不应该依赖它不需要的接口。
类间的依赖关系应该建立在最小的接口上。
通俗的讲:接口尽量细化,同时接口中的方法尽可能的少。
提供给每个模块的都应该是单一接口,提供给几个模块就应该有几个接口,而不是建立一个庞大的臃肿的接口,容纳所有的客户端访问。
接口是我们设计时对外提供的契约,通过分散定义多个接口,可以预防未来变更的扩散,提高系统的灵活性和可维护性。
含义:
接口尽量少这是接口隔离原则的核心定义,不出现臃肿的接口(Fat Interface),但是“小”是有限度的,首先就是不能违反单一职责原则。
根据接口隔离原则拆分接口时,首先必须满足单一职责原则。
接口要高内聚
高内聚就是要提高接口,类,模块的处理能力,减少对外的交互。
具体到接口原则就是,要求在接口中尽可能少公布public方法,接口是对外的承诺,承诺地越少对系统开发越有利,变更的风险也就越少,同时也利于降低成本。
定制服务
定制服务就是单独为一个个体提供优良的服务。
接口设计是有限度的
接口的设计粒度越小,系统越灵活,这是不争的事实。但是,灵活的同时也带来了结构的复杂化,开发难度增加,可维护性降低,这不是一个项目或产品所期望的,所以接口设计一定要注意适度,这个度只能根据经验和常识判断,没有一个固话或可测量的标准。
相关文章推荐
- 接口隔离原则(ISP--Interface Segregation Principle)
- 设计模式六大原则——接口隔离原则(ISP,Interface Segregation Principle)
- 设计模式六大原则(4):接口隔离原则ISP(Interface Segregation Principle)
- ISP( Interface Segregation Principle)接口隔离原则
- 接口隔离原则(Interface Segregation Principle,ISP)
- 接口隔离原则(ISP--Interface Segregation Principle)
- 接口隔离原则(ISP - Interface Segregation Principle)
- "围观"设计模式(4)--接口隔离原则(ISP,Interface Segregation Principle)
- "围观"设计模式(4)--接口隔离原则(ISP,Interface Segregation Principle)
- ISP(Interface Segregation Principle),接口隔离原则
- ISP(Interface Segregation Principle),接口隔离原则
- Java设计模式之接口隔离原则(Interface Segregation Principle, ISP)
- 接口隔离原则(Interface Segregation Principle)ISP
- 设计原则-接口隔离原则(Interface Segregation Principle)
- 接口隔离原则(Interface Segregation Principle)
- 接口隔离原则【Interface Segregation Principle】
- Interface Segregation Principle (ISP) - OO设计的接口分隔原则
- 六大设计原则--接口隔离原则【 Interface Segregation Principle】
- 接口隔离原则(Interface segregation principle)
- 设计模式六大原则(4)接口隔离原则(Interface Segregation Principle)