关于我在SOLID中的问题 [英] Question about the I in SOLID

查看:74
本文介绍了关于我在SOLID中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直在学习SOLDID原则。



我声明你不应该有不必要的方法。



在SOLID中,我代表接口隔离原则。



但是你需要一个接口来应用这个方法吗?



一个班级不一样吗?



我尝试过:



我在这里检查了其他文章并用Google搜索了它。

So I have been learning about SOLDID-principles.

The I states that you should not have unnecessary methods.

In SOLID I stands for Interface Segregation principle.

But do you need an interface to apply this method?

Isn't it the same for a class?

What I have tried:

I have checked other articles both here and Googled it.

推荐答案

接口制作应用这个更容易,但不是必需的。您可以使用具有较窄范围的方法的继承和类来实现此目的。但是,正确的界面使其更容易。
Interfaces make applying this easier but it's not required. You can achieve this using inheritance and classes that have a narrower scope of methods. However to do properly interfaces makes it a lot easier.


这篇关于关于我在SOLID中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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