为何实施? [英] Why Implementation?

查看:70
本文介绍了为何实施?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果没有真正有理由拥有它,微软就不会因为包括语言实现而感到困扰。但是,如果我能看到它有什么好处的话,我会被诅咒。对于初学者来说,你必须确保所有已实施的成员都在场,无论你是否打算使用

。这本身就很麻烦。


为什么不保持简单 - 构建一个类,然后实例化

并使用它的成员?更多 - 我甚至很少使用遗产 - 似乎对我来说是意大利面条代码。


然而又一次,我的大脑往往被包裹在一个不时有雾。如果我是
导致我错过了一些可以改善我的一般方法的东西,我会确定想知道它。


所以有问题,我想 - 为什么要实施?


TIA,

Jeff


If there weren''t a real strong reason for having it, Microsoft wouldn''t have
bothered with including Implementation in the language. But doggone it, I''ll be
darned if I can see what''s so great about it. For starters, you''ve got to make
sure all the implemented members are present, whether you''re going to use them
or not. That''s cumbersome enough all by itself.

Why not just keep things nice and simple--build a class, and then instantiate it
and use its members? Much more--I rarely even use inheritance--seems like
spaghetti code to me.

But then again, my brain tends to get wrapped in a fog from time to time. If I''m
causing myself to miss out on something that''d improve my general approach, I''d
sure like to know about it.

So there''s the question, I guess--Why Implementation?

TIA,
Jeff


推荐答案

" Jeff Bowman" < WR ********* @ my.addess.com>写在

新闻:eB ************** @ TK2MSFTNGP12.phx.gbl:
"Jeff Bowman" <wr*********@my.addess.com> wrote in
news:eB**************@TK2MSFTNGP12.phx.gbl:
首先,你有确保所有已实施的成员都在场,无论您是否打算使用它们。这本身就很麻烦了。


这是合同。

实例化并使用其成员?更多 - 我甚至很少使用
继承 - 看起来像意大利面条代码给我。
For starters, you''ve got to make sure all the implemented members are
present, whether you''re going to use them or not. That''s cumbersome
enough all by itself.
Thats the contract.
instantiate it and use its members? Much more--I rarely even use
inheritance--seems like spaghetti code to me.




Ouch - 继承对任何OO设计都至关重要。 />

-

Chad Z. Hower(又名Kudzu) - http://www.hower.org/Kudzu/

编程是一种反击的艺术形式

使您的ASP.NET应用程序运行得更快
http:// www.atozed.com/IntraWeb/



Ouch - inheritance is vital to any OO design.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Make your ASP.NET applications run faster
http://www.atozed.com/IntraWeb/


Jeff Bowman写道:
Jeff Bowman wrote:
如果没有真正有理由拥有它,微软不会对包括语言实现在内的人感到困扰。但是,如果我能看到它有什么好处的话,我会感到很沮丧。首先,你必须制作
If there weren''t a real strong reason for having it, Microsoft wouldn''t have
bothered with including Implementation in the language. But doggone it, I''ll be
darned if I can see what''s so great about it. For starters, you''ve got to make



我认为你指的是接口实现。考虑

Adob​​e Photoshop。它有一个可用的插件菜单,每个插件都以某种方式操纵图像。但是,这些插件并不是必须由Adobe编写的。它们可以由第三方编写。

当PS加载插件时,它不知道插件是如何实现的。
。它只知道插件支持一个特定的集合

方法(读取:接口)。


对于插件设计者,他没有必要知道怎么回事

Adob​​e调用这些方法。只要他遵守合同,他就知道他的插件将与PS一起工作。


考虑微软自己的ADO.Net。它提供了一个IDbConnection

接口。可以创建各种后端来实现这个

接口。例如,SQLConnection对象实现了

接口。 Oracle有一个连接对象,它也实现了这个

接口。


应用程序设计师只需要编写接口代码和

这样做,后端数据库可以更改而无需重新编译他的代码。


这些是简单的例子,但我认为它们有助于显示价值

界面编程。



I presume you are referring to Interface Implementation. Consider
Adobe Photoshop. It has a menu of available plugins that each
manipulate the image in some way. These plugins, however, are not
necessarily written by Adobe. They could be written by third parties.
When PS loads the plugin, it has no idea of how the plugin is
implemented. It only knows that the plugins support a particular set
of methods (read: interface).

For the plugin designer, he doesn''t have to know anything about how
Adobe calls the methods. So long as he follows the contract, he knows
his plugin will work with PS.

Conside Microsoft''s own ADO.Net. It provides an IDbConnection
interface. Various backends can be created that implement this
interface. For example the SQLConnection object implements the
interface. Oracle has a connection object that also implements this
interface.

The application designer only needs to code to the interface and in
doing so, the backend database can be changed without having to
recompile his code.

These are simple examples but I think that they help show the value of
interface programming.


Chad Z. Hower aka Kudzu< cp ** @ hower.org>写道:
Chad Z. Hower aka Kudzu <cp**@hower.org> wrote:
实例化并使用其成员?更多 - 我甚至很少使用
继承 - 看起来像意大利面条代码。
instantiate it and use its members? Much more--I rarely even use
inheritance--seems like spaghetti code to me.



Ouch - 继承对于任何OO设计都至关重要。



Ouch - inheritance is vital to any OO design.




我非常强烈地不同意这一点。我倾向于使用继承来聚合而不是使用
。它偶尔会有用,而且它*有用的地方

它绝对是无价之宝。但是,编写应该继承的类 - 特别是在你自己的程序集之外 - 需要很多

更多的工作才能正确地完成它,你的实现最终可能会成为一个

不太灵活,因为你需要坚持使用相同的规则

方法调用哪种方法等等。


有一篇关于这个的好文章 - 我希望我能找到它...


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复小组,请不要给我发邮件



I disagree with that pretty strongly. I tend to aggregate rather than
using inheritance. It''s useful occasionally, and where it *is* useful
it''s absolutely invaluable. However, writing classes which should be
inherited from - especially outside your own assembly - requires a lot
more work to do it properly, and your implementation can end up being a
lot less flexible, as you need to stick to the same rules about which
method calls which other method etc.

There''s a good article about this somewhere - I wish I could find it...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于为何实施?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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