Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Object Oriented Programming (OOP)

Reply
Thread Tools

Object Oriented Programming (OOP)

 
 
tom_usenet
Guest
Posts: n/a
 
      05-21-2004
On Fri, 21 May 2004 07:53:08 -0400, "Pmb" <(E-Mail Removed)>
wrote:

>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 makes it much easier to modify behaviour in large projects (and to
think about what should be modifiable), and also gives a reasonable
way of structuring such projects.

>2) Can OOP be accomplished with non-object oriented languages such as C?


Yes, but the syntax is a mess.

>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?


For small projects I sometimes use "object based" programming, using
classes to divide the program into modules. Many small projects (as in
just a few thousand LOC) have little scope to use polymorphism
themselves, but even then I'll usually use OOP libraries at some
point. Any time you write "std::cout" you are using OOP...

Tom
--
C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
 
Reply With Quote
 
 
 
 
Pmb
Guest
Posts: n/a
 
      05-21-2004

"Allan Bruce" <(E-Mail Removed)> wrote in message
news:c8kte3$473$(E-Mail Removed)2surf.net...
> > Thanks.
> >
> > As I asked Nevyn, would you use OOP if you were writing a program to do

> some
> > number crunching, e.g. solving a differential equation etc.?
> >
> > Pmb
> >
> >

>
> It entirely depends!
>
> I would use OOP if it were part of a bigger project, no two ways about it.
> For example, one class may be a solver for differenial equations. One

could
> have linear ODEs and others done within this class.
>
> If you mean, would I program an OOP just to solve one equation, then the
> answer is no. I would do it in Matlab!


No. I'm thinking more or less number crunching with C++. E.g. suppose you
were tasked with creating a library function for the confluent
hypergeometric function of the first kind, or something as equally
obnoxious.

One can't always turn to Mathlab, especially if you don't have it.

>
> Basically, what I am trying to say is, if I am programming something of
> medium scale or larger, then I would do it using OOP, if it is small

scale,
> i.e. a few lines of code, then I wouldn't program it in a low-level
> language, I would use other tools, e.g. Matalab.


and if you were someone like me who didn't have Matlab?

Thanks

Pmb


 
Reply With Quote
 
 
 
 
G. Morgen
Guest
Posts: n/a
 
      05-21-2004
I suggest another name: OOPS
Object Oriented Ploughramming Swine
 
Reply With Quote
 
Allan Bruce
Guest
Posts: n/a
 
      05-21-2004

"Pmb" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "Allan Bruce" <(E-Mail Removed)> wrote in message
> news:c8kte3$473$(E-Mail Removed)2surf.net...
> > > Thanks.
> > >
> > > As I asked Nevyn, would you use OOP if you were writing a program to

do
> > some
> > > number crunching, e.g. solving a differential equation etc.?
> > >
> > > Pmb
> > >
> > >

> >
> > It entirely depends!
> >
> > I would use OOP if it were part of a bigger project, no two ways about

it.
> > For example, one class may be a solver for differenial equations. One

> could
> > have linear ODEs and others done within this class.
> >
> > If you mean, would I program an OOP just to solve one equation, then the
> > answer is no. I would do it in Matlab!

>
> No. I'm thinking more or less number crunching with C++. E.g. suppose you
> were tasked with creating a library function for the confluent
> hypergeometric function of the first kind, or something as equally
> obnoxious.
>
> One can't always turn to Mathlab, especially if you don't have it.
>
> >
> > Basically, what I am trying to say is, if I am programming something of
> > medium scale or larger, then I would do it using OOP, if it is small

> scale,
> > i.e. a few lines of code, then I wouldn't program it in a low-level
> > language, I would use other tools, e.g. Matalab.

>
> and if you were someone like me who didn't have Matlab?
>
> Thanks
>
> Pmb
>
>


I think what you are trying to get at, is, OOP is slower for number
crunching. If so, then this is rubbish. Why would it be slower? OOP is
just as fast as any other programming paradigm for number crunching. If
this is not what you are trying to get at, then perhaps rephrasing your
question is needed?

OOP is about design, number crunching is an implementation within a design.
Cant say much more without clarification of what you want to know...

Allan


 
Reply With Quote
 
G. Morgen
Guest
Posts: n/a
 
      05-21-2004
> I suggest another name: OOPS
> Object Oriented Ploughramming Swine


Progscriptum: No personal offence meant
 
Reply With Quote
 
Derek
Guest
Posts: n/a
 
      05-21-2004
Pmb wrote:
> 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?


The big three reasons to use it (encapsulation,
inheritance, polymorphism) help me structure code in a
well-defined, maintainable, and (usually) reusable way.

> 2) Can OOP be accomplished with non-object oriented
> languages such as C?


Absolutely, but it's not pretty. There are whole C
libraries that are OO by convention, but it's not a pretty
sight. If you want OOP, it's best to use a language that
supports it directly.

> 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?


See #1. Even if I don't plan to reuse code, OOP helps me
organize problems in a well-defined, maintainable form.
This has value even if I'm the only customer, so to speak.
Also remember that C++ is a multi-paradigm language:
it support OOP, but doesn't require it. If structured
programming makes more sense than OOP for a part of your
problem, then C++ lets you mix SP and OOP freely. That's a
big reason it's so powerful.
 
Reply With Quote
 
Pmb
Guest
Posts: n/a
 
      05-21-2004

"Allan Bruce" <(E-Mail Removed)> wrote

> I think what you are trying to get at, is, OOP is slower for number
> crunching. If so, then this is rubbish. Why would it be slower? OOP is
> just as fast as any other programming paradigm for number crunching. If
> this is not what you are trying to get at, then perhaps rephrasing your
> question is needed?


That wasn't what I was getting to. I was wondering if some problems more
readily lend themselves to structured programming in that they are easier to
write etc. Speed was not what I had in mind. OOP works best when you're
modeling real world objects right? What about abstract things for which
there may be no real world thing which to model.? Area under a curve etc.
Perhaps math wasn't the best example to use but it was what came to mind.
I'll have better questions as I learn.

Pmb


 
Reply With Quote
 
Pmb
Guest
Posts: n/a
 
      05-21-2004

"Derek" <(E-Mail Removed)> wrote

>If structured
> programming makes more sense..


That's what I'm thinking. Do you know of a way to describe in general when
to use OOP rather than structured programming? I.e. are some types of tasks
better left to structured programming?

Thanks

Pmb


 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      05-21-2004
Claudio Puviani writes:

> > 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?

>
> If you're not a professional carpenter, but you have to put in a screw,

will you
> use a hammer just because it's only for your personal use? Of course not.

You use
> the tool that's most appropriate to what you're doing. You use OOP if the
> solution can be best expressed in an OO manner. If it can best be

expressed
> otherwise, you don't use OOP.


As I understood the OPs question, and if you wish to use analogies, ISTM a
more appropriate analogy would be "Would you build a skyscraper out of
wood?"

People working alone produce small programs. A group of a 100 or so
programmers face a new set of problems.

I have been thinking of posting a longer message to this thread if I get
around to it, but for now I would say that if a problem has a lot of
"state", it is probably time to use OOP. Continuing the C vs. C++ base, (as
opposed to a generic OOP base): if you find yourself using more than a very
few static variables, I think you've got an OOP problem on your hands.


 
Reply With Quote
 
Allan Bruce
Guest
Posts: n/a
 
      05-21-2004

"Pmb" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "Allan Bruce" <(E-Mail Removed)> wrote
>
> > I think what you are trying to get at, is, OOP is slower for number
> > crunching. If so, then this is rubbish. Why would it be slower? OOP

is
> > just as fast as any other programming paradigm for number crunching. If
> > this is not what you are trying to get at, then perhaps rephrasing your
> > question is needed?

>
> That wasn't what I was getting to. I was wondering if some problems more
> readily lend themselves to structured programming in that they are easier

to
> write etc. Speed was not what I had in mind. OOP works best when you're
> modeling real world objects right? What about abstract things for which
> there may be no real world thing which to model.? Area under a curve etc.
> Perhaps math wasn't the best example to use but it was what came to mind.
> I'll have better questions as I learn.
>
> Pmb
>
>


Ok, I understand now. There are definately some examples that are obvious to
be implemented in OOP. Other problems may not be as obvious, for example
your maths example. Here, there are no 'objects' as such, but this is when
I use OOP for modules. For example, I would create a class for my Maths
Module, and one for my GUI.. This isnt OOP as such, but you can still
benefit from the advantages of OOP.
Allan


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
New C++ Book - C++ For Artists: The Art. Philosophy, And Science Of Object-Oriented Programming Rick Miller C++ 1 09-19-2013 02:55 AM
class-oriented rather than object-oriented? notnorwegian@yahoo.se Python 2 05-26-2008 04:42 PM
C (functional programming) VS C++ (object oriented programming) Joe Mayo C Programming 168 10-22-2007 01:00 AM
Object oriented does not mean class oriented rolo Ruby 3 04-09-2004 02:51 PM
About object oriented programming Martin C++ 5 09-11-2003 06:15 PM



Advertisments