为什么我们使用面向对象编程 [英] why we use object oriented programming

查看:94
本文介绍了为什么我们使用面向对象编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

面试问题



为什么我们使用面向对象的编程以及面向对象编程的用途。

解决方案

为什么?因为如果你遵守这些规则,它会使复杂的代码更容易开发,更可靠,更易于维护,并且通常更好。



因为OOP坚持你在想什么在暴露给外部世界时,它允许您在不影响任何其他代码的情况下更改对象的实现。 (封装)

因为它允许你拥有许多不同的功能,所有功能都具有相同的名称,所有功能都在做同样的工作,但是在不同的数据上。 (多态)

因为它可以让你编写通用代码:它可以处理一系列数据,所以你不必一遍又一遍地编写基本的东西。 (泛型)

因为它允许你编写一组函数,然后以不同的方向展开它们,而不以任何方式更改或复制它们。 (继承)



还有其他原因,但这些都是相当不错的原因!


不好的问题,因为它是修辞的,包含答案。



它想通过立即限制你的想法来恐吓你:



为什么 - 我们 - 使用。



简直不礼貌,愚蠢和荒谬。

正确的问题应该是 WHEN (不是为什么),或为什么以及为什么不



面试官在这里期待什么?

有人投掷烟花照亮了整个编程科学的夜晚,同时解释了OOP的美丽以及为什么世界各地不应该有其他任何东西?!?



他们知道吗那个C ++ STL不是(我重复:不是)OOP?

他们知道几乎没有OOP进入lambda吗?

他们知道OOP是只是一种技巧,而不是一种宗教?



这是增量在选择人时涉及多少愚蠢。



他们在寻找什么?有人默默地服从他们的上帝,或者能够思考的人吗?


为什么要使用OOP?



我们来看看在OOP概念出现之前,有一个程序编程,它将设计软件作为一系列功能和程序进行精确焊接。这使得软件变得很复杂,难以理解和维护。



OOP引入了寻求软件设计的新概念:真实世界的对象概念。

这个概念将生成软件作为单独的代码模块,它可以提升解耦并增加代码的可重用性。

OOP中解耦的一个常见用途是多态解耦封装。

对于可重用性,它由继承和泛型概念引入。

请参阅解决方案1,快速定义多态性,泛型,继承和封装。



希望这会有所帮助。


interview question

why we use object oriented programming and what is the uses of object oriented programming.

解决方案

Why? Because if you stick to the rules, it makes complex code easier to develop, more relieable, more maintainable, and generally better.

Because OOP insists that you think about what you expose to the outside world, it lets you change the implementation of an object without affecting any other code. (Encapsulation)
Because it allows you to have many different functions, all with the same name, all doing the same job, but on different data. (Polymorphism)
Because it lets you write generic code: which will work with a range of data, so you don't have to write basic stuff over, and over again. (Generics)
Because it lets you write a set of functions, then expand them in different direction without changing or copying them in any way. (Inheritance)

There are other reasons, but those are pretty good ones!


Bad question, since it is rhetorical and contains the answer.

It wants to intimidate you by immediately restricting your thinking:

WHY - WE - USE.

Simply not polite, stupid and ridiculous.
The proper question should have been WHEN (not WHY), or WHY and WHY NOT.

What is the interviewer expecting here?
Someone throwing fireworks illuminating all the night of programming science while explain the beautifulness of OOP and why there shouldn't be anything else about that around the world ?!?

Do they know that the C++ STL is NOT (I repeat: is NOT) OOP ?
Do they know that there is almost no OOP into a lambda?
Do they know that OOP is just a technique, not a religion?

It is incredible how many stupidity is involved in selecting people.

What are they seeking for? Someone silently obeying to their god, or someone that is able to think?


Why to use OOP ?

Let's take a look before OOP concepts coming, there was "Procedural" programming which concist of designing a software as a bunch of functions and procedures verry welded.Thus Softwares becomes quickly complexe, hard to understand and to maintain.

The OOP introduced new concepts for looking to softwares design : real world Object concept.
This concept will come to produce softwares as seperated code modules which riseup decoupling and increases code re-usability.
A common use of decoupling in OOP is to polymorphically decouple the encapsulation.
For reusibility it is introduced by Inheritance and Generics concepts.
See Solution 1 to have a quick definition of Polymorphism, generics, inheritance and encapsualtion.

Hope this helps.


这篇关于为什么我们使用面向对象编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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