到底是什么"基于接口的编程和QUOT;?到底是什么、接口、QUOT

由网友(溺爱和你)分享简介:我经常听到/读到基于接口编程,但我不是什么真正的含义是很清楚。基于接口编程的实际独立的话题,实际上有书写什么呢?如果是的话,任何人都可以推荐任何好的?I often hear/read about interfaced based programming but I am not exactly clear on w...

我经常听到/读到基于接口编程,但我不是什么真正的含义是很清楚。基于接口编程的实际独立的话题,实际上有书写什么呢?如果是的话,任何人都可以推荐任何好的?

I often hear/read about interfaced based programming but I am not exactly clear on what that really means. Is interfaced based programming an actual stand alone topic that actually has books written about it? If so, can anyone recommend any good ones?

我碰到接口编程基础,我正在读关于如何好API的设计,并希望更多地了解它。现在,我并不清楚如何正确去周围接口设计的API。

I came across interface based programming as I was reading about how good APIs are designed and would like to learn more about it. Right now I am not clear how to properly go about designing an API around interfaces.

任何信息大大AP preciated。

Any info is greatly appreciated.

感谢。

推荐答案

这基本上EX $ P $的问题pssing您的依赖的的接口,而不是具体的类(或更糟的是,静态方法计算)。所以,如果你的一个类需要进行身份验证,就应提供一个 IAuthenticator (或其他)。

It's basically a matter of expressing your dependencies in terms of interfaces instead of concrete classes (or worse, static methods). So if one of your classes needs to perform authentication, it should be provided an IAuthenticator (or whatever).

这意味着:

您可以实现真正的依赖关系之前写code 您可以通过轻松地嘲讽真正测试(而不必mock类,它得到丑陋的) 很明显是你依靠的API,而不是执行方面(即你有更松散的耦合)
阅读全文

相关推荐

最新文章