面向对象编程(OOP) [英] Object Oriented Programming (OOP)

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

问题描述

您好。我是这个小组的新手。我正在刷新/学习C ++并开始学习面向对象编程(OOP)。在与人们讨论这个问题时,我们简要介绍了OOP的优点。例如:由于我理解它,OOP在软件重用方面有其主要优势。因此,人们开发了一个类的软件库,这减少了重新发明轮子的开销。有人可能会说这可以通过使用函数库进行结构化编程来完成。所以我有几个问题。


1)对于那些喜欢OOP的人,你为什么喜欢它?

2)OOP可以用非面向对象的语言,如C?

3)如果您不是软件工程团队的一员,而是从您自己的使用中编程
并且不要是否需要重复使用代码才能使用OOP?


谢谢


Pmb

Hi. I''m new to this group. I''m refreshing/learning C++ and am starting to
learn Object Oriented Programming (OOP). In discussing this with people I
came up short as to what the benefits of OOP are. For example: As I
understand it, OOP has its main benefit in software reuse. Thus one develops
a software library of classes and this cuts down the overhead of reinventing
the wheel. Someone might say that this can be done with structured
programming with function libraries. So I have a few questions.

1) For those of you who like OOP, why do you like it?
2) Can OOP be accomplished with non-object oriented languages such as C?
3) If you''re not part of a software engineering team but are programming
from your own use and don''t need to reuse code would you bother with OOP?

Thanks

Pmb

推荐答案



" Pmb" <所以***** @ somewhere.com>在消息中写道

news:b4 ******************** @ comcast.com ...

"Pmb" <so*****@somewhere.com> wrote in message
news:b4********************@comcast.com...
你好。我是这个小组的新手。我正在刷新/学习C ++,并开始学习面向对象编程(OOP)。在与人们讨论这个问题时,我简要介绍了OOP的优点。例如:我理解它,OOP在软件重用方面有其主要优势。因此,一个
开发了一个类的软件库,这减少了
重新发明轮子的开销。有人可能会说这可以通过使用函数库进行结构化编程来完成。所以我有几个问题。

1)对于那些喜欢OOP的人,你为什么喜欢它?


在我看来,它强制设计出更好的设计,并提供数据隐藏功能。另一个

优势是减少了传入和传出

函数的参数,因为许多方法访问类中的成员变量

2)可以OOP是用非面向对象语言完成的,比如C?


它可以模拟,但从我所看到的非常凌乱,并且不是

可读。

3)如果你不是软件工程团队的一员,而是根据自己的使用进行编程,不需要重用代码就可以了吗?
Hi. I''m new to this group. I''m refreshing/learning C++ and am starting to
learn Object Oriented Programming (OOP). In discussing this with people I
came up short as to what the benefits of OOP are. For example: As I
understand it, OOP has its main benefit in software reuse. Thus one develops a software library of classes and this cuts down the overhead of reinventing the wheel. Someone might say that this can be done with structured
programming with function libraries. So I have a few questions.

1) For those of you who like OOP, why do you like it?
It forces a better design in my opinion, and offers data hiding. Another
advantage is the reduced amount of parameters transferred to and from
functions, since many methods access member variables within a class
2) Can OOP be accomplished with non-object oriented languages such as C?
It can be emulated, but from what I have seen is very messy, and isnt
readable.
3) If you''re not part of a software engineering team but are programming
from your own use and don''t need to reuse code would you bother with OOP?




我为了愉快而节目并且出于多种原因使用它,这里有一个例子:


我有一个我正在编程的游戏。我游戏中的实体遵循

简单的heirarchy:


类GameEntity //指定Step()和Draw()的接口。有一个

成员变量bool有效


类发货:public GameEntity //定义一艘有Shoot(),Die()



class PlayerShip:publilc Ship //定义已输入的玩家船舶

控制等


我遵循一个类似的风景,通电等等。它使事情

a很多整洁,如果你把方法整合到层次结构中高达

可能,重复的代码越少。


Allan



I program for pleasure and use it for many reasons, here is an example:

I have a game which I am programming. The entities in my game follow a
simple heirarchy:

class GameEntity // specifies interface for Step() and Draw(). Has one
member variable "bool Valid"

class Ship : public GameEntity // define a ship which has Shoot(), Die()
etc.

class PlayerShip : publilc Ship // defines the player ship which has input
controls etc.

I follow a similar heirarchy for scenery, for powerups etc. It makes things
a lot neater, and if you incorporate the methods as high up the hierarchy as
possible, the less duplicate code there is.

Allan


这将是我的第一篇文章小组以及......


我自己才开始使用OOP。你进入的那种思维方式很有意思。虽然我仍然认为很多OOP

的实现很简单,但确实可以更容易地将你的代码与真正的对象联系起来。


就个人而言,我认为两者都有自己的位置,但OOP允许你封装

这些东西比直接结构更好。


C不允许OOP推送的封装,因此不适合OOP
- 但是如果你不是一个规则而且想要制作的东西

对自己来说有点难度,看到OOP似乎是一种心态

比什么都重要,C甚至pascal应该能够做到这一点

一些奇怪和奇怪的程度。


如果编程供自己使用,我仍然认为OOP是值得的。如果在某个晚些时候您希望再次查看代码,那么很容易

查看单个对象并确切知道它们与
而不是试图找出每个函数。这可以用

当然可以修改评论,但为什么还要麻烦,如果你可以编写代码呢?


通过与偶像小项目的朋友合作,我找到了

,我们每个人都可以在一个物体上工作,将它们拉到一起并完成所有工作

与所涉及的工作很少一起工作。


希望这至少回答你的一些问题...


问候,Nevyn。


周五,2004年5月21日07:53:08 -0400,Pmb写道:
Hi, this will be my first post to this group as well...

I''ve only just started using OOP myself. It''s kind of interesting the sort
of mind set you get into. Although I still believe that alot of OOP
implementation is done just plain badly it does make it easier to relate
your code to real ''objects''.

Personally I think both have their place but OOP allows you encapsulate
things a hell of alot better than just straight stuctured.

C doesn''t allow for the encapsulation that OOP pushes and so is unsuitable
for OOP - but if you aren''t one for the rules and want to make things a
hell of alot harder on yourself, seeing as OOP seems to be a mentality
more than anything, C and possibly even pascal should be able to do it to
some strange and wierd extent.

If programming for your own use, I still think OOP is worthwhile. If at
some later date you wish you go over the code again, it''s alot easier
looking at the individual objects and knowing exactly what they relate to
rather than trying to figure out each of the functions. This could of
course be fixed with comments but why bother if you can just code it in?

From working with a friend on the occassional little project, I''ve found
that we can each work on an object each, pull them together and get it all
working together with very little work involved.

Hope this at least answers some of your questions...

regards, Nevyn.

On Fri, 21 May 2004 07:53:08 -0400, Pmb wrote:
嗨。我是这个小组的新手。我正在刷新/学习C ++,并开始学习面向对象编程(OOP)。在与人们讨论这个问题时,我简要介绍了OOP的优点。例如:我理解它,OOP在软件重用方面有其主要优势。因此,人们开发了一个类的软件库,这减少了重新发明轮子的开销。有人可能会说这可以通过使用函数库进行结构化编程来完成。所以我有几个问题。

1)对于那些喜欢OOP的人,你为什么喜欢它?
2)OOP可以用非面向对象的语言完成,比如C ?
3)如果你不是软件工程团队的一员,而是从你自己的使用中编程而不需要重用代码,你会不会为OOP而烦恼?

谢谢

Pmb
Hi. I''m new to this group. I''m refreshing/learning C++ and am starting to
learn Object Oriented Programming (OOP). In discussing this with people I
came up short as to what the benefits of OOP are. For example: As I
understand it, OOP has its main benefit in software reuse. Thus one develops
a software library of classes and this cuts down the overhead of reinventing
the wheel. Someone might say that this can be done with structured
programming with function libraries. So I have a few questions.

1) For those of you who like OOP, why do you like it?
2) Can OOP be accomplished with non-object oriented languages such as C?
3) If you''re not part of a software engineering team but are programming
from your own use and don''t need to reuse code would you bother with OOP?

Thanks

Pmb








< ne *** @的localhost.localdomain>在留言中写道

news:pa **************************** @ localhost.loca ldomain ...

<ne***@localhost.localdomain> wrote in message
news:pa****************************@localhost.loca ldomain...
这也是我在这个小组中的第一篇文章...

我自己刚刚开始使用OOP。你进入的思维方式有点有趣。虽然我仍然认为很多OOP
的实现很简单,但确实可以让您更容易将代码与真实的对象联系起来。

我个人认为两者都有它们的位置,但是OOP允许你封装的东西比直接结构更好。

C不允许OOP推动的封装,所以不适合
如果编程为自己使用,我仍然认为OOP是值得的。如果在以后某个日期你希望再次查看代码,那么查看单个对象并确切知道它们与
的关系而不是试图找出它是很容易的。每个功能。这当然可以通过评论来解决,但是如果你可以编写代码那么为什么呢?

通过与偶像小项目的朋友合作,我找到了
我们每个人都可以在一个物体上工作,将它们拉到一起并完成所有工作
同时完成很少的工作。

希望这至少能回答你的一些问题......
Hi, this will be my first post to this group as well...

I''ve only just started using OOP myself. It''s kind of interesting the sort
of mind set you get into. Although I still believe that alot of OOP
implementation is done just plain badly it does make it easier to relate
your code to real ''objects''.

Personally I think both have their place but OOP allows you encapsulate
things a hell of alot better than just straight stuctured.

C doesn''t allow for the encapsulation that OOP pushes and so is unsuitable
for OOP - but if you aren''t one for the rules and want to make things a
hell of alot harder on yourself, seeing as OOP seems to be a mentality
more than anything, C and possibly even pascal should be able to do it to
some strange and wierd extent.

If programming for your own use, I still think OOP is worthwhile. If at
some later date you wish you go over the code again, it''s alot easier
looking at the individual objects and knowing exactly what they relate to
rather than trying to figure out each of the functions. This could of
course be fixed with comments but why bother if you can just code it in?

From working with a friend on the occassional little project, I''ve found
that we can each work on an object each, pull them together and get it all
working together with very little work involved.

Hope this at least answers some of your questions...




是的。谢谢。


如果你正在编写程序进行一些数字处理,你会使用OOP吗,

例如求解微分方程等?


Pmb



Yes. Thanks.

Would you use OOP if you were writing a program to do some number crunching,
e.g. solving a differential equation etc.?

Pmb


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

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