到底是什么"基于接口的编程和QUOT;? [英] What exactly is "interface based programming"?

查看:158
本文介绍了到底是什么"基于接口的编程和QUOT;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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,而不是执行方面(即你有更松散的耦合)

这篇关于到底是什么"基于接口的编程和QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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