试图了解接口的用途 [英] Trying to understand the purpose of interfaces

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

问题描述

我无法理解界面的目的,甚至

虽然界面的概念一直在我身边(例如用户

界面)。我只是不理解软件

接口。


像其他任何东西一样,看起来接口设计的东西是

需要文件。我知道这可能是显而易见的,但如果我有一个

类A,我说,好吧,A类实现了IMyInterface。实现IMyInterface的事实

应该对我有意义。我猜测,MS和其他Sun有很多明确的定义和

记录的接口,我最终会关心它们。


我想我正在寻找他们缺席需要他们的时间。

我认为通过看到他们失踪的特定情况

需要他们(或者会没有它们会很难),我可能会看到并且

了解他们的必要性和理解。


有没有人有这方面的例子?我希望这是有道理的。


谢谢。

I am having trouble understanding the purposes of an interface, even
though the concept of interfaces is around me all the time (user
interface, for example). I''m just not understanding software
interfaces.

Like anything else, it appears Interfaces are by design something that
requires documentation. I know this may be obvious, but if I have a
class A and I say, well, class A implements IMyInterface. The fact
that it implements IMyInterface is supposed to mean something to me. I
am guessing that MS and other Sun have a lot of well defined and
documented interfaces that I would eventually care about.

I guess I am looking for a time when their absence would require them.
I think that by seeing their missing from a given situation that
requires them (or would be hard without them), I might see and
understand their necessity and understand.

Does anyone have an example of this? I hope this made some sense.

Thank you.

推荐答案

" jm" ; < ne *********** @ gmail.com写信息

新闻:11 ******************* ***@i42g2000cwa.googlegr oups.com ...
"jm" <ne***********@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...

如果我有一个

A级,我说,好吧,上课一个实现IMyInterface。实现IMyInterface的事实

应该对我有意义。
if I have a
class A and I say, well, class A implements IMyInterface. The fact
that it implements IMyInterface is supposed to mean something to me.



这意味着您可以使用该类的对象,其中

类型的对象需要IMyInterface。


否则,它只是意味着在类中实现了IMyInterface方法/属性

,但你不需要使用它的接口

单独的目的。


// ark

What it means is that you can use an object of that class where an object of
type IMyInterface is expected.

Otherwise, it just means that IMyInterface methods/properties are
implemented in the class, but you wouldn''t need to use an interface for that
purpose alone.

//ark


Hello JM,


最近讨论过。请参阅 http:// petesbloggerama。 blogspot.com/...nterfaces.html


JI无法理解界面的用途,甚至

虽然概念是接口一直在我身边(例如,用户

Jinterface)。我只是不理解软件

Jinterfaces。

J>

JLike其他任何东西,它看起来接口是设计的东西

Jthat需要文档。我知道这可能是显而易见的,但是如果我这是一个A类而且我说,好吧,A类实现了IMyInterface。它实现IMyInterface的那个
Jfact应该意味着什么呢?
Jme。我猜测MS和其他Sun有很多明确的定义

Jand记录了我最终会关心的接口。

J>

我想我正在寻找他们缺席需要的时间

Jthem。我认为,通过在特定情况下看到他们的失踪

Jthat需要他们(或没有他们会很难),我可能会看到并且

了解他们的必要性和理解。

J>

J有没有人有这方面的例子?我希望这是有道理的。

J>

JThank你。<​​br />
J>

---

WBR,

Michael Nemtsev ::博客: http://spaces.live.com/laflour


有时一个人仍然忠实于一个事业,只因为它的对手没有

不再是平淡的。 (c)Friedrich Nietzsche
Hello JM,

Have discussed recently. See there http://petesbloggerama.blogspot.com/...nterfaces.html

JI am having trouble understanding the purposes of an interface, even
Jthough the concept of interfaces is around me all the time (user
Jinterface, for example). I''m just not understanding software
Jinterfaces.
J>
JLike anything else, it appears Interfaces are by design something
Jthat requires documentation. I know this may be obvious, but if I
Jhave a class A and I say, well, class A implements IMyInterface. The
Jfact that it implements IMyInterface is supposed to mean something to
Jme. I am guessing that MS and other Sun have a lot of well defined
Jand documented interfaces that I would eventually care about.
J>
JI guess I am looking for a time when their absence would require
Jthem. I think that by seeing their missing from a given situation
Jthat requires them (or would be hard without them), I might see and
Junderstand their necessity and understand.
J>
JDoes anyone have an example of this? I hope this made some sense.
J>
JThank you.
J>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


jm ...只需将界面视为合约即可。无论何时软件

合同都可以考虑编写接口。一个例子是网络

服务。您将
程序添加到ISomeUsefulNetworkService接口。任何客户都可以在网络上查看



您的服务并与您的特定

实施互动
ISomeUsefulNetworkService只要你实施

ISomeUsefulNetworkService。您的竞争对手也可以实施自己的实现此接口的
网络服务。对客户来说,

实际

的实现细节是隐藏的。客户只需拨打

界面

,即可使用任何实现该界面的网络服务。


问候,

Jeff


***通过Developersdex发送 http://www.developersdex.com ***
jm... Just look at an interface as a contract. Wherever a software
contract would
be useful consider writing an interface. An example is a network
service. You
program to the interface ISomeUsefulNetworkService. Any client can look
up
your service on the network and interact with your particular
implementation of
ISomeUsefulNetworkService as long as you implement
ISomeUsefulNetworkService. Your competitors can also implement their own
network service that implements this interface. To the client, the
actual
implementation details are hidden. The client simply makes calls to the
interface
and can utilize any network service that implements the interface.

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***


这篇关于试图了解接口的用途的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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