接口隔离原理 - 编程到接口 [英] Interface Segregation Principle- Program to an interface

查看:160
本文介绍了接口隔离原理 - 编程到接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读有关SOLID和其他设计原则。我认为ISP与程序到接口而不是实现相同。但是看起来这些是不同的原则?



有没有区别?

解决方案>

ISP主要关注每个接口代表一个离散和内聚行为的想法。



也就是说,对象应该做的每一个逻辑组的事情都将映射到一个单一的特定界面。类可能需要做几件事情,但每一件事情都会映射到表示该行为的特定接口。这个想法是每个界面都非常关注。


I was reading about SOLID and other design principles. I thought ISP was the same as "Program to an interface, not an implementation". But it looks like these are different principles?

Is there a difference?

解决方案

ISP is focused on the idea of each interface representing one discrete and cohesive behavior.

That is, each logical group of things an object should do would map to a single specific interface. A class might want to do several things, but each thing would map to a specific interface representing that behavior. The idea is each interface is very focused.

这篇关于接口隔离原理 - 编程到接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆