设计原则-接口隔离原则(Interface Segregation Principle)
来源:互联网 发布:淘宝2016双十一销售额 编辑:程序博客网 时间:2024/05/16 10:31
意图
使接口粒度合适
定义:客户端不应该依赖它不需要的接口;一个类对另一个类的依赖应该建立在最小的接口上。
建立单一接口,不要建立庞大臃肿的接口,尽量细化接口,接口中的方法尽量少。
使用多个隔离的接口,比使用单个接口更好。还是一个降低类之间的耦合度的意思,从这儿我们看出,其实设计模式就是软件的设计思想,从大型软件架构出发,为了升级和维护方便。
“降低依赖,降低耦合”优点
通过分散定义多个接口,可以预防外来变更的扩散,提高系统的灵活性和可维护性注意事项
1.接口尽量小,但是要有限度
2.为依赖接口的类定制服务,只暴露给调用的类它需要的方法,它不需要的方法则隐藏起来。只有专注地为一个模块提供定制服务,才能建立最小的依赖关系。
3.提高内聚,减少对外交互。使接口用最少的方法去完成最多的事情。与单一职责原则区别
1.单一职责原则原注重的是职责;而接口隔离原则注重对接口依赖的隔离。
2.单一职责原则主要是约束类,其次才是接口和方法,它针对的是程序中的实现和细节;而接口隔离原则主要约束接口接口,主要针对抽象,针对程序整体框架的构建。
0 0
- 设计原则-接口隔离原则(Interface Segregation Principle)
- 接口隔离原则(Interface Segregation Principle)
- 接口隔离原则(Interface Segregation Principle)
- 接口隔离原则(Interface segregation principle)
- 【六大设计原则】4. 接口隔离原则 -Interface Segregation Principle
- 六大设计原则--接口隔离原则【 Interface Segregation Principle】
- 软件设计原则(五)接口隔离原则 -Interface Segregation Principle
- 接口隔离原则(Interface Segregation Principle)
- 接口隔离原则(Interface Segregation Principle)
- 接口隔离原则【Interface Segregation Principle】
- ISP(Interface Segregation Principle),接口隔离原则
- 接口隔离原则【Interface Segregation Principle】
- Interface Segregation Principle 接口隔离原则
- 设计模式六大设计原则之接口隔离原则(Interface Segregation Principle)
- 设计模式六大原则(4):接口隔离原则ISP(Interface Segregation Principle)
- 设计模式六大原则(4):接口隔离原则(Interface Segregation Principle)
- 设计模式六大原则(4)接口隔离原则(Interface Segregation Principle)
- 设计模式6大原则之接口隔离原则(Interface Segregation Principle)
- Vim_删除空格
- SQL_left join中on和where条件的区别
- Java_poi多sheet分批次导出
- $.ajax()方法详解
- Java_获取键盘输入值的三种方法
- 设计原则-接口隔离原则(Interface Segregation Principle)
- javascript 实现ajax调用,重点是纯的js实现
- 做一名优秀的开发者可没有说的那么简单
- 反超苹果!谷歌成为美国最有价值品牌
- Eclipse install svn plugin(link)
- javaSE_06Java中的数组(array)-提高练习
- Delphi中打开网页连接的几种方法
- Eclipse_background indexer crash recovery java.lang.stackoverflowerror
- Spring