多重继承辩论II:根据斯特劳斯特鲁普(Stroustrup)的观点 [英] Multiple Inheritance Debates II: according to Stroustrup

查看:77
本文介绍了多重继承辩论II:根据斯特劳斯特鲁普(Stroustrup)的观点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常了解关于为什么接口继承比多重继承更受欢迎的传统论点,这里已经有一篇文章: C#是否应具有多重继承?

I know very well about the traditional arguments about why Interface Inheritance is prefered to multiple inheritance, there has been already a post here : Should C# have multiple inheritance?

但是,根据Stroustrup所说,Microsoft和Sun决定摆脱多重继承的真正原因是他们既有这样做的兴趣:他们没有在语言中添加功能,而是将它们放在框架中,以便人们可以与之绑定.他们的平台,而不是在语言标准级别具有相同功能的人.

But according to Stroustrup the real reason why Microsoft and Sun decided to get rid off multiple inheritance is that they have vested interest to do so: instead of putting features in the languages, they put in frameworks so that people then become tied to their platform instead of people having the same capability at a language standard level.

您怎么看?

为什么Sun和Microsoft认为开发人员太不成熟,不能自己做出选择?

Why Sun and Microsoft consider developers too immature to just make the choice themselves ?

以上是我对他所说内容的明确解释.当然,他的确以一种在政治上更正确的方式说了这一点:)

Above is my explicit interpretation of what he said. Of course he did say that in a more politically-correct way :)

节选自与Bjarne Stroustrup的对话" http://www.artima.com/intv/modern.html

Excerpt from "A Conversation with Bjarne Stroustrup" http://www.artima.com/intv/modern.html

人们很正确地说你 不需要多重继承, 因为你可以做的任何事情 您也可以执行多重继承 单继承.你只用 我提到的代表团技巧. 此外,您不需要任何 根本没有继承 您可以通过单一继承来做 也可以不继承 通过课程转发.实际上, 您也不需要任何课程, 因为你可以用 指针和数据结构.但为什么 你想这样做吗?什么时候 语言使用方便 设施?您什么时候需要一个 解决方法?我看过一些案例 多重继承很有用,并且 我什至见过很多情况 复杂的多重继承是 有用.通常,我更喜欢使用 语言提供的设施 解决方法.

People quite correctly say that you don't need multiple inheritance, because anything you can do with multiple inheritance you can also do with single inheritance. You just use the delegation trick I mentioned. Furthermore, you don't need any inheritance at all, because anything you do with single inheritance you can also do without inheritance by forwarding through a class. Actually, you don't need any classes either, because you can do it all with pointers and data structures. But why would you want to do that? When is it convenient to use the language facilities? When would you prefer a workaround? I've seen cases where multiple inheritance is useful, and I've even seen cases where quite complicated multiple inheritance is useful. Generally, I prefer to use the facilities offered by the language to doing workarounds.

摘自"Developpeur Reference采访Bjarne Stroustrup"

From "Interview of Bjarne Stroustrup by "Developpeur Reference""

http://www2.research.att.com/〜bs/nantes-interview-english.html

您始终可以将使用多重继承的示例重写为仅在使用单一继承的情况下(通过使用转发功能).但是,结果通常是一个示例,该示例更长,更直接地反映了设计并且难以维护.请注意,您还可以使用相同的技术将使用单继承的每个示例重写为不使用继承的示例,并且对代码清晰度具有相同的负面影响.与支持多重继承的语言相比,不支持多重继承的语言表达能力较低,从而迫使程序员偶尔使代码复杂化.

You can always re-write an example using multiple inheritance into on the uses single inheritance only (by using forwarding functions). However, the result is often an example that is longer, reflect the design less directly, and is harder to maintain. Note that you can also rewrite every example using single inheritance to an example using no inheritance using the same technique and with the same negative impact on code clarity. A language that does not support multiple inheritance is simply less expressive than one that supports multiple inheritance and thereby forces the programmer to occasionally complicate code.

...

人们谈论了很多框架,但是历史充斥着没有达到他们期望的框架.我看到了成功的框架,但是它们的范围通常受到限制.我对通用"框架表示怀疑,当此类框架是平台供应商与其他供应商的类似框架竞争的产品时,我更持怀疑态度.作为用户,我希望尽可能地保持与供应商的独立性.

People talk a lot about frameworks, but history is littered with frameworks that didn't live up to their expectations. I have seen successful frameworks, but they were generally limited in scope. I'm skeptical of "universal" frameworks, and even more so when such frameworks are products of a platform vendor competing with similar frameworks from other vendors. As a user, I prefer to maintain my independence from vendors as far as possible.

我希望看到图书馆为框架提供更干净,更通用的访问权限-而不是与单个框架紧密相关的语言.

I'd like to seen libraries providing cleaner and more general access to frameworks - as opposed to languages intimately tied to a single framework.

推荐答案

我自己的想法:

人们的确追随时尚,IT也不例外.除非有些大师有兴趣这样做,否则没人敢质疑基本原理.

People do follow fashion and IT is no exception. Nobody dares to question the fundamentals until some Gurus have themselves interest to do so.

例如,在Java的情况下,直到Rod Johnson提出另一个受.NET实用主义启发的框架之前,没人敢质疑EJB.

For example in the case of Java nobody dared to question EJB until Rod Johnson came along with another framework which he said was inspired by .NET pragmatism.

现在,.NET借助EF变得越来越框架化.

And now .NET is becoming itself more and more frameworklish with EF.

这篇关于多重继承辩论II:根据斯特劳斯特鲁普(Stroustrup)的观点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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