OOP在大学里被滥用了吗?[英] Is OOP abused in universities?

本文是小编为大家收集整理的关于OOP在大学里被滥用了吗?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我两年前开始了大学,从那时起,我一直在听"设计您的课程".有时候我真的问自己,我的解决方案应该首先成为一堆物体!有人说您看不到它的好处,因为您的代码库很小 - 大学项目.项目规模的借口只是不要掉下我的喉咙.如果解决方案与该项目相处得很好,我相信该项目也应该是该项目的宏观变换.

我并不是说OOP很糟糕,我只是觉得这是在像我这样的学生中被告知oop是正确的方式.

imho,正确的答案不应该来自教授,我更喜欢从现场的真正工程师那里听到.

OOP是正确的方法吗?

什么时候OOP是最佳方法?

什么时候oop是不良的方法?

这是一个非常普遍的问题.我不是在要求确定的答案,只是该领域的一些真正的设计经验.

我不在乎性能.我在问设计.我知道这是现实生活中的工程.

=================================================== ===============================

感谢所有贡献.我选择了诺斯雷纳的答案,因为她总体上解决了我的问题,并说服了我对以下方面的意思是错误的: 如果该解决方案与该项目相处得很好,我相信该项目也应该是该项目的宏观变换.

推荐答案

教授的缺点是,他们不能让您参加多年来持续多年的庞大,令人讨厌的程序,并由许多不同的程序员开展工作.他们必须使用相当令人信服的玩具示例,并试图欺骗您看到更大的图景.

本质上,他们必须吓到您相信,当Ho仪表型火车撞到您时,它会撕掉您的腿.只有最有说服力的教授才能做到.


"如果该解决方案与该项目相处得很好,我相信该项目也应该是该项目的宏观变换."

那是我不同意的地方.一个小项目适合您的大脑.它的大版本可能不是.对我来说,OO的好处是隐藏了足够多的细节,以便大图仍然可以塞进我的脑海.如果您缺乏OO,您仍然可以管理,但这意味着寻找其他方法来隐藏复杂性.

请密切关注真正的目标 - 生产可靠的代码. OO在大型程序中效果很好,因为它可以帮助您管理复杂性.它也可以帮助可重复使用.

,但oo不是目标.好代码是目标.如果程序方法起作用,并且永远不会变得复杂,那么您赢了!

其他推荐答案

OOP是一个现实的计算机概念,该大学将被抛弃在课程中.当您申请工作时,您将在其中熟悉.

话虽如此,pace jalf,OOP主要是设计为管理复杂性的一种方式.一两个学生在作业时间上写的大学项目并不是这样的大型项目的现实环境,因此示例感觉(并且是)玩具示例.

此外,重要的是要意识到并非每个人都以同样的方式看到OOP.有些人看到了有关封装的信息,并举办了非常复杂的大型课程,但对任何外部呼叫者都隐藏了状态.其他人则想确保给定的对象只负责做一件事并进行很多小课.有些人寻求一种对象模型,该模型紧密反映了该程序试图与之相关的现实世界摘要,另一些对象模型将对象模型视为如何组织问题的技术架构,而不是现实世界业务模型. 没有一种真正的方式 ,它的核心是作为管理复杂性和使较大程序随着时间更加维护而引入的.

其他推荐答案

oop是正确的方法,当您的数据构成对象中.

例如,对于正在处理传感器传入字节流的嵌入式设备,可能没有太多可以明确客观化的.

在对性能的绝对控制至关重要的情况下(每个周期计数),OOP方法可能会引入可能不利于计算的成本.

在现实世界中,大多数情况下,您的问题可以用对象很好地描述,尽管漏水定律不得忘记!

行业通常会在大多数情况下最终解决工作的正确工具,并且您可以在许多地方看到OOP.经常为高性能和低水平做例外.当然,没有艰难的规则.

如果粘在螺钉中足够长的时间,您可以用螺丝锤...

本文地址:https://www.itbaoku.cn/post/627415.html

问题描述

I started my college two years ago, and since then I keep hearing "design your classes first". I really ask myself sometimes, should my solution to be a bunch of objects in the first place! Some say that you don't see its benefits because your codebase is very small - university projects. The project size excuse just don't go down my throat. If the solution goes well with the project, I believe it should be the right one also with the macro-version of that project.

I am not saying OOP is bad, I just feel it is abused in classrooms where students like me are told day and night that OOP is the right way.

IMHO, the proper answer shouldn't come from a professor, I prefer to hear it from real engineers in the field.

Is OOP the right approach always?

When is OOP the best approach?

When is OOP a bad approach?

This is a very general question. I am not asking for definite answers, just some real design experience from the field.

I don't care about performance. I am asking about design. I know it is engineering in real life.

==================================================================================

Thankful for all contributions. I chose Nosredna answer, because she addressed my questions in general and convinced me that I was wrong about the following : If the solution goes well with the project, I believe it should be the right one also with the macro-version of that project.

推荐答案

The professors have the disadvantage that they can't put you on huge, nasty programs that go on for years, being worked on by many different programmers. They have to use rather unconvincing toy examples and try to trick you into seeing the bigger picture.

Essentially, they have to scare you into believing that when an HO gauge model train hits you, it'll tear your leg clean off. Only the most convincing profs can do it.


"If the solution goes well with the project, I believe it should be the right one also with the macro-version of that project."

That's where I disagree. A small project fits into your brain. The large version of it might not. To me, the benefit of OO is hiding enough of the details so that the big picture can still be crammed into my head. If you lack OO, you can still manage, but it means finding other ways to hide the complexity.

Keep your eye on the real goal--producing reliable code. OO works well in large programs because it helps you manage complexity. It also can aid in reusability.

But OO isn't the goal. Good code is the goal. If a procedural approach works and never gets complex, you win!

其他推荐答案

OOP is a real world computer concept that the university would be derelict to leave out of the curriculum. When you apply for jobs, you will be expected to be conversant in it.

That being said, pace jalf, OOP was primarily designed as a way to manage complexity. University projects written by one or two students on homework time are not a realistic setting for large projects like this, so the examples feel (and are) toy examples.

Also, it is important to realize that not everyone really sees OOP the same way. Some see it about encapsulation, and make huge classes that are very complex, but hide their state from any outside caller. Others want to make sure that a given object is only responsible for doing one thing and make a lot of small classes. Some seek an object model that closely mirrors real world abstractions that the program is trying to relate to, others see the object model as about how to organize the technical architecture of the problem, rather than the real world business model. There is no one true way with OOP, but at its core it was introduced as a way of managing complexity and keeping larger programs more maintainable over time.

其他推荐答案

OOP is the right approach when your data can be well structured into objects.

For instance, for an embedded device that's processing an incoming stream of bytes from a sensor, there might not be much that can be clearly objectified.

Also in cases where ABSOLUTE control over performance is critical (when every cycle counts), an OOP approach can introduce costs that might be nontrivial to compute.

In the real world, most often, your problem can be VERY well described in terms of objects, although the law of leaky abstractions must not be forgotten!

Industry generally resolves, eventually, for the most part, to using the right tool for the job, and you can see OOP in many many places. Exceptions are often made for high-performance and low-level. Of course, there are no hard and fast rules.

You can hammer in a screw if you stick at it long enough...