OOP的意义是什么? [英] What's the point of OOP?

查看:112
本文介绍了OOP的意义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,尽管在OOP教育,语言和工具上花费了数百万或数十亿美元,但OOP并没有提高开发人员的生产力或软件可靠性,也没有降低开发成本.很少有人严格地使用OOP(很少有人坚持或理解LSP等原则);人们用来建模问题域的方法似乎几乎没有统一性或一致性.通常,该类仅用于其语法糖.它将记录类型的函数放入它们自己的小命名空间中.

As far as I can tell, in spite of the countless millions or billions spent on OOP education, languages, and tools, OOP has not improved developer productivity or software reliability, nor has it reduced development costs. Few people use OOP in any rigorous sense (few people adhere to or understand principles such as LSP); there seems to be little uniformity or consistency to the approaches that people take to modelling problem domains. All too often, the class is used simply for its syntactic sugar; it puts the functions for a record type into their own little namespace.

我已经为各种应用程序编写了大量代码.尽管在某些场合中,真正的可替代子类型在应用程序中发挥了重要作用,但这些情况非常例外.通常,尽管提供了很多口头禅来谈论重用",但现实是,除非某段代码准确地做到了您想要的目的,否则几乎没有成本效益的重用". -使用".以正确的方式将类设计为可扩展的极为困难,因此扩展的成本通常很高,以至于重用"根本就不值得.

I've written a large amount of code for a wide variety of applications. Although there have been places where true substitutable subtyping played a valuable role in the application, these have been pretty exceptional. In general, though much lip service is given to talk of "re-use" the reality is that unless a piece of code does exactly what you want it to do, there's very little cost-effective "re-use". It's extremely hard to design classes to be extensible in the right way, and so the cost of extension is normally so great that "re-use" simply isn't worthwhile.

在很多方面,这并不令我感到惊讶.现实世界不是"OO",OO中隐含的想法(我们可以用某种分类法对事物建模)在我看来从根本上来说是有缺陷的(我可以坐在桌子,树桩,汽车引擎盖上) ,某人的膝盖-但其中之一不是-椅子).即使我们转向更抽象的领域,OO建模通常也很困难,违反直觉并且最终无济于事(请考虑圆形/椭圆形或正方形/矩形的经典示例).

In many regards, this doesn't surprise me. The real world isn't "OO", and the idea implicit in OO--that we can model things with some class taxonomy--seems to me very fundamentally flawed (I can sit on a table, a tree stump, a car bonnet, someone's lap--but not one of those is-a chair). Even if we move to more abstract domains, OO modelling is often difficult, counterintuitive, and ultimately unhelpful (consider the classic examples of circles/ellipses or squares/rectangles).

那么我在这里想念什么? OOP的价值在哪里?为什么所有的时间和金钱都无法使软件变得更好?

So what am I missing here? Where's the value of OOP, and why has all the time and money failed to make software any better?

推荐答案

没有经验证据表明面向对象是人们思考世界的更自然的方式.程序设计心理学领域的一些工作表明,OO在某种程度上并不比其他方法更合适.

There's no empirical evidence that suggests that object orientation is a more natural way for people to think about the world. There's some work in the field of psychology of programming that shows that OO is not somehow more fitting than other approaches.

面向对象的表示形式似乎并没有普遍使用或使用较少.

Object-oriented representations do not appear to be universally more usable or less usable.

仅仅采用面向对象的方法并要求开发人员使用这种方法是不够的,因为这可能会对开发人员的生产率以及所开发系统的质量产生负面影响.

It is not enough to simply adopt OO methods and require developers to use such methods, because that might have a negative impact on developer productivity, as well as the quality of systems developed.

摘自ACM Communications 2000年10月的关于OO表示的可用性"的文章.文章主要将OO与面向过程的方法进行了比较.关于使用面向对象方法思考"的人们的工作方式有很多研究(Int.J. Human-Computer Studies 2001年,第54期,或Human-Computer Interaction 1995,第10卷以面向对象研究为主题),从我的阅读中,没有什么迹象表明面向对象方法具有某种自然性,使其比传统的程序方法更适合.

Which is from "On the Usability of OO Representations" from Communications of the ACM Oct. 2000. The articles mainly compares OO against theprocess-oriented approach. There's lots of study of how people who work with the OO method "think" (Int. J. of Human-Computer Studies 2001, issue 54, or Human-Computer Interaction 1995, vol. 10 has a whole theme on OO studies), and from what I read, there's nothing to indicate some kind of naturalness to the OO approach that makes it better suited than a more traditional procedural approach.

这篇关于OOP的意义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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