嗯,你怎么知道什么时候制作界面? :-) [英] Erm, how do you know when to make an interface? :-)

查看:57
本文介绍了嗯,你怎么知道什么时候制作界面? :-)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

节日祝福其他程序员!


我现在已经编程了大约4年,也许5年了。那些年中有4年

在大学就读,而且我没有太多的工作经验来制作真正的世界应用程序(虽然我现在试图制作一些)。在制作节目时我还不知道有多少b $ b很多。我知道所有的理论,

但不知道在现实世界的项目中如何(和为什么)完成某些事情。


我当前的思考是关于接口的。我想我理解了

理论 -


接口用于定义两个实体之间的合约。一个实体

实现了一个接口,另一个实体可以针对那个

接口进行编程,并且知道运行时有什么对象 - 只要

接口已实现 - 一切都会好的。


嗯,那很好。我可以理解为什么这可能是一个好主意

场合(理论上)。你可以说 - 好吧,我不想知道实际物体是什么原因

;我只是想知道它将履行其

义务。


我不知道的是 - 知道何时创建界面。


你怎么知道的?哪些对象应该为它们创建接口?我没有

得到了一个线索,因为我从来没有被教过它。


我正在尝试制作一个可以存储的电子邮件应用程序

文件系统上的消息。我想知道我是否应该制作任何

接口 - 但我只是不知道。


我可以创建一个接口大量的物品,但我不确定

点是什么。我确定我应该至少有一些接口,但我不知道
知道在哪里制作它们等等。这真的是一个实施问题。


任何人都可以就如何发现潜在的

接口提供一些一般性的建议。我的意思是,必须有一些方法;某种规则

开发人员有意或无意地申请。如果有人能够提供任何关于如何发现/确定接口何时应该是b
的建议,那么这将是非常好的。

非常感谢任何可以提供帮助的人。


亲切的问候


Simon

Festive greetings fellow programmers!

I''ve been programming now for about 4, maybe 5 years now. 4 of those years
were at university so and I havent had much work experience of making real
world applications (although I trying to make some now). There is still a
lot I don''t know when it comes to making programs. I know all the theory,
but not how (and why) certain things are done in real world projects.

My current ponderings are about interfaces. I think I understand the
theory -

An interface is used to define a contract between two entities. One entity
implements an interface, and the other entity can program against that
interface and know that whatever object is there at runtime - as long as the
interface is implemented - everything will be fine.

Well, thats nice then. I can understand why that might be a good idea on
occasion (in theory). You being able to say - "Ok, I don''t want to know what
the actual object is as such; I just want to know that it will fulfill its
obligations".

The thing I''m crap at is - knowing when to create an interface.

How do you know? What objects should have interfaces made for them? I havent
got a clue because I was never taught about it.

I''m currently trying to make an email application that will store received
messages on the file system. I''m trying to figure out if I should make any
interfaces - but I just don''t know.

I could make an interface for loads of objects, but I''m not sure what the
point would be. I''m sure I should have at least some interfaces, but I don''t
know where to make them and so on. It''s really a problem of implementation.

Could anyone offer me some general advice on how you can spot potential
interfaces. I mean, there must be some approach to it; some sort of rules
that developers either conciously or subconsiously apply. If anyone could
offer any advice at all on how to spot/determine when an interface should be
employed, then that would be excellent.

Many thanks to anyone who can help.

Kind Regards

Simon

推荐答案

Simon Harvey写道:
Simon Harvey wrote:
我不知道的是 - 知道何时创建界面。
The thing I''m crap at is - knowing when to create an interface.




当我遇到一些我认为可能会成为

继承的情况时,我立即回溯并查看界面是否更多

感。它通常会这样。


没有硬性规定。当您发现需要从不同的

对象进行统一行为时,它应该是您的第一件事。例如,如果您的电子邮件应用程序支持插件,那么您将需要开发一个界面,以便您可以在不知道任何相关信息的情况下操作这些插件。


-

有10种人。那些懂二元的人和那些没有b $ b的人。

http://code.acadx.com

(拉针回复)



The moment I come across something that I think might make a case for
inheritance, I immediately backtrack and see if an interface makes more
sense. And it usually does.

There''s no hard and fast rule. It should just be the first thing on your
mind when you discover a need for uniform behavior from disparate
objects. For example, if your email app will support plugins, you''ll
want to develop an interface so you can operate those plugins without
knowing anything about them.

--
There are 10 kinds of people. Those who understand binary and those who
don''t.

http://code.acadx.com
(Pull the pin to reply)


如果你想要定义外观和感觉没有实际确定某些外观意味着什么,或者某种感觉是什么然后使用接口。

" Simon Harvey" < sh856531@microsofts_free_email_service.com>在消息中写道

news:uN ************** @ tk2msftngp13.phx.gbl ...
If you want to define a "look and feel" without actually determining what a
certain look means or what a certain feel does then use interfaces.
"Simon Harvey" <sh856531@microsofts_free_email_service.com> wrote in message
news:uN**************@tk2msftngp13.phx.gbl...
节日问候同事们的程序员!

我现在已经编程了大约4年,也许5年了。那些年中有4年
在大学就读,而且我没有太多的工作经验来制作真正的世界应用程序(虽然我现在试图制作一些)。在编写程序方面,我还有很多我不知道的事情。我知道所有理论,但不知道如何(以及为什么)在现实世界的项目中完成某些事情。

我目前的思考是关于接口。我想我理解了
理论 -

接口用于定义两个实体之间的契约。一个实体实现了一个接口,另一个实体可以对该接口进行编程,并且知道运行时有任何对象 - 只要
接口实现 - 一切都会好的。

好吧,那很好。我可以理解为什么这可能是一个好主意(理论上)。你可以说 - 好吧,我不想知道
实际物体是这样的;我只想知道它将履行其
义务。

我不知道的是 - 知道何时创建界面。

你怎么知道的?哪些对象应该为它们创建接口?我没有得到任何线索,因为我从未接受过关于它的教育。

我正在尝试制作一个电子邮件应用程序,它将在文件系统上存储收到的消息。我正在试图弄清楚我是否应该制作任何
接口 - 但我只是不知道。

我可以为大量物体制作一个界面,但我''我不确定
点会是什么。我确定我应该至少有一些接口,但是我不知道在哪里制作它们等等。这实际上是
实施的问题。
任何人都可以就如何发现潜在的
接口提供一些一般性的建议。我的意思是,必须有一些方法;某些规则
开发人员无论是有意还是潜意识地应用。如果有人能提供任何关于如何发现/确定何时应该使用
接口的建议,那么这将是非常好的。

非常感谢任何可以提供帮助的人。

亲切的问候

Simon
Festive greetings fellow programmers!

I''ve been programming now for about 4, maybe 5 years now. 4 of those years
were at university so and I havent had much work experience of making real
world applications (although I trying to make some now). There is still a
lot I don''t know when it comes to making programs. I know all the theory,
but not how (and why) certain things are done in real world projects.

My current ponderings are about interfaces. I think I understand the
theory -

An interface is used to define a contract between two entities. One entity
implements an interface, and the other entity can program against that
interface and know that whatever object is there at runtime - as long as the interface is implemented - everything will be fine.

Well, thats nice then. I can understand why that might be a good idea on
occasion (in theory). You being able to say - "Ok, I don''t want to know what the actual object is as such; I just want to know that it will fulfill its
obligations".

The thing I''m crap at is - knowing when to create an interface.

How do you know? What objects should have interfaces made for them? I havent got a clue because I was never taught about it.

I''m currently trying to make an email application that will store received
messages on the file system. I''m trying to figure out if I should make any
interfaces - but I just don''t know.

I could make an interface for loads of objects, but I''m not sure what the
point would be. I''m sure I should have at least some interfaces, but I don''t know where to make them and so on. It''s really a problem of implementation.
Could anyone offer me some general advice on how you can spot potential
interfaces. I mean, there must be some approach to it; some sort of rules
that developers either conciously or subconsiously apply. If anyone could
offer any advice at all on how to spot/determine when an interface should be employed, then that would be excellent.

Many thanks to anyone who can help.

Kind Regards

Simon



至于面向对象的编程可以看作是尝试在编程语言和现实世界之间进行类比,接口与

继承可以看作是对象之间的区别_being_

某事物和一个物体_doing_某事。如果一个班级A能够做到b $ b * foo *,而另一个班级B需要使用许多不同的对象来支持
做* foo *,行为,foo,应该是一个接口,这样不同的A / B $ B类比A可以实现接口,而且B将能够使用它们

all。但是,如果B类不需要* do * foo的类,但是

*的类是* bar,那么继承更适合这种情况。你可以决定在行为和身份之间划清界线。


克里斯C.
As far as object-oriented programming can be seen as an attempt to make
analogies between programming languages and the real world, interfacing vs.
inheritance can be seen as the difference between an object _being_
something and an object _doing_ something. If a class, A, is able to do
*foo*, and another class, B, needs to use a number of different objects that
do *foo*, the behavior, foo, should be an interface, so that different
classes than A can implement the interface, and B will be able to use them
all. However, if class B needs not classes that *do* foo, but classes that
*are* bar, then inheritance is more appropriate for the situation. It''s up
to you to decide where to draw the line between behavior and identity.

Chris C.


这篇关于嗯,你怎么知道什么时候制作界面? :-)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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