Object Oriented Programming (OOP)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pmb

    Object Oriented Programming (OOP)

    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


  • Allan Bruce

    #2
    Re: Object Oriented Programming (OOP)


    "Pmb" <someone@somewh ere.com> wrote in message
    news:b4WdnUr-IbM4cDDdRVn-hg@comcast.com. ..[color=blue]
    > 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[/color]
    develops[color=blue]
    > a software library of classes and this cuts down the overhead of[/color]
    reinventing[color=blue]
    > 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?[/color]

    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
    [color=blue]
    > 2) Can OOP be accomplished with non-object oriented languages such as C?[/color]

    It can be emulated, but from what I have seen is very messy, and isnt
    readable.
    [color=blue]
    > 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?
    >[/color]

    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


    Comment

    • nevyn@localhost.localdomain

      #3
      Re: Object Oriented Programming (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...

      regards, Nevyn.

      On Fri, 21 May 2004 07:53:08 -0400, Pmb wrote:
      [color=blue]
      > 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[/color]

      Comment

      • Pmb

        #4
        Re: Object Oriented Programming (OOP)


        <nevyn@localhos t.localdomain> wrote in message
        news:pan.2004.0 5.21.12.03.43.3 39350@localhost .localdomain...[color=blue]
        > 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...[/color]

        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


        Comment

        • Pmb

          #5
          Re: Object Oriented Programming (OOP)


          "Allan Bruce" <allanmb@TAKEAW AYf2s.com> wrote in message
          news:c8kraq$3fv $1@news.freedom 2surf.net...[color=blue]
          >
          > "Pmb" <someone@somewh ere.com> wrote in message
          > news:b4WdnUr-IbM4cDDdRVn-hg@comcast.com. ..[color=green]
          > > Hi. I'm new to this group. I'm refreshing/learning C++ and am starting[/color][/color]
          to[color=blue][color=green]
          > > learn Object Oriented Programming (OOP). In discussing this with people[/color][/color]
          I[color=blue][color=green]
          > > 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[/color]
          > develops[color=green]
          > > a software library of classes and this cuts down the overhead of[/color]
          > reinventing[color=green]
          > > 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?[/color]
          >
          > 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
          >[color=green]
          > > 2) Can OOP be accomplished with non-object oriented languages such as C?[/color]
          >
          > It can be emulated, but from what I have seen is very messy, and isnt
          > readable.
          >[color=green]
          > > 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[/color][/color]
          OOP?[color=blue][color=green]
          > >[/color]
          >
          > 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[/color]
          things[color=blue]
          > a lot neater, and if you incorporate the methods as high up the hierarchy[/color]
          as[color=blue]
          > possible, the less duplicate code there is.[/color]

          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


          Comment

          • Allan Bruce

            #6
            Re: Object Oriented Programming (OOP)

            > Thanks.[color=blue]
            >
            > As I asked Nevyn, would you use OOP if you were writing a program to do[/color]
            some[color=blue]
            > number crunching, e.g. solving a differential equation etc.?
            >
            > Pmb
            >
            >[/color]

            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!

            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.

            Allan


            Comment

            • bartek

              #7
              Re: Object Oriented Programming (OOP)

              "Pmb" <someone@somewh ere.com> wrote in
              news:V86dnaXYBc qNaTDdRVn-hw@comcast.com:

              (...)
              [color=blue]
              > Would you use OOP if you were writing a program to do some number
              > crunching, e.g. solving a differential equation etc.?[/color]

              Why not? http://www.oonumerics.org/

              "Object oriented" describes a programming paradigm. As all other paradigms,
              you can see it in different perspectives, depending on your own point of
              view.

              C++ being a multi-paradigm language, allows you to freely mix OO concepts
              with plain imperative 'C' programming style, and even functional style.
              On one hand, it's much more versatile and powerful. On the other, it gives
              *a lot* of opportunities for misuse. This is all obvious, though. :)

              --
              :: bartekd [at] o2 [dot] pl

              Comment

              • Shashank

                #8
                Re: Object Oriented Programming (OOP)

                Hi Pmb,

                I like component programming in C++. I also like programming OOP. Simply because
                it allows you to comprehend the problems/ solution in terms of objects rather
                then functions. It just allows you to structure your program better then what is
                possible using even C but in a easier way.

                Encapsulation, polymorphism, inheritance are features are OOAD and can be
                achieved using C as well, but yeah simple to achieve or design in C++.

                Similarly re-use or not you may do in C as well as C++. Its just because you can
                comprehend the problem and solution easier in OO methodology that enhances
                chances of writing code that may be re-used.

                So you will find, moving from C to C++ (or object oriented) is primarily because
                it allows to create well structured software easily (because of some features as
                mentioned above, that are by default part of objects then in structure where
                you will have to code for it!!) compared to structure language.

                regards,
                Shashank

                Pmb wrote:
                [color=blue]
                > 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[/color]

                Comment

                • Jeff Relf

                  #9
                  Pan and zoom vs. OOP.

                  Hi Pmb, a.k.a. Pete,

                  In an e-mail, you asked me why I think OOP is modal.

                  Google, " define:modal ":

                  " Pertaining to modes. "
                  ...
                  " A dialog is modal if its parent application
                  is blocked from further activity
                  ^^^^^^^
                  until the dialog has completed. See non-modal. "

                  OOP is a hierarchy,
                  and, like all hierarchies, it's usually overdone.

                  The flatter one can keep one's data
                  the more accessible it becomes.

                  For example, take a perfectly flat map of the world,
                  a user simply pans and zooms to see what he wants.
                  No need to go browsing through
                  some absurd tree of rigid directories,
                  branching here and there, going ever deeper,
                  getting ever more lost.

                  That's the problem with OOP, it's too convoluted.

                  I hate pop-ups for the same reason,
                  as each dialog window pops up, you enter another mode,
                  it's annoying. Flat is where it's at.

                  In my programs I make a real effort to
                  eliminate All pop-ups.
                  I also don't like sub-sub-sub-sub menus.

                  So I replace them with a maximized window
                  ( where my Win98 taskbar is the only other window ).

                  Then I navigate using different combinations and durations
                  of buttons on my 5 button wheel mouse ...
                  So that everything is accessible all the time,
                  no need to consider what mode I might be in.

                  The terrain ( i.e. the data ) is keep flat like a map ...
                  I just pan and zoom.

                  Comment

                  • Claudio Puviani

                    #10
                    Re: Object Oriented Programming (OOP)

                    "Pmb" <someone@somewh ere.com> wrote[color=blue]
                    > 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?[/color]

                    Managing complexity is a cornerstone of programming and OOP is one tool that
                    helps do that. C++ offers other paradigms, including structured and generic
                    programming, that also help in managing complexity.
                    [color=blue]
                    > 2) Can OOP be accomplished with non-object oriented languages
                    > such as C?[/color]

                    Yes it can. It's just less automated. In the same vein, you can do functional,
                    declarative, and symbolic programming with C++. The language just doesn't give
                    you shortcuts to do so.
                    [color=blue]
                    > 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?[/color]

                    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.

                    Claudio Puviani


                    Comment

                    • tom_usenet

                      #11
                      Re: Object Oriented Programming (OOP)

                      On Fri, 21 May 2004 07:53:08 -0400, "Pmb" <someone@somewh ere.com>
                      wrote:
                      [color=blue]
                      >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?[/color]

                      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.
                      [color=blue]
                      >2) Can OOP be accomplished with non-object oriented languages such as C?[/color]

                      Yes, but the syntax is a mess.
                      [color=blue]
                      >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?[/color]

                      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

                      Comment

                      • Pmb

                        #12
                        Re: Object Oriented Programming (OOP)


                        "Allan Bruce" <allanmb@TAKEAW AYf2s.com> wrote in message
                        news:c8kte3$473 $1@news.freedom 2surf.net...[color=blue][color=green]
                        > > Thanks.
                        > >
                        > > As I asked Nevyn, would you use OOP if you were writing a program to do[/color]
                        > some[color=green]
                        > > number crunching, e.g. solving a differential equation etc.?
                        > >
                        > > Pmb
                        > >
                        > >[/color]
                        >
                        > 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[/color]
                        could[color=blue]
                        > 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![/color]

                        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.
                        [color=blue]
                        >
                        > 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[/color]
                        scale,[color=blue]
                        > 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.[/color]

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

                        Thanks

                        Pmb


                        Comment

                        • G. Morgen

                          #13
                          oops [was: Re: Object Oriented Programming (OOP)]

                          I suggest another name: OOPS
                          Object Oriented Ploughramming Swine

                          Comment

                          • Allan Bruce

                            #14
                            Re: Object Oriented Programming (OOP)


                            "Pmb" <someone@somewh ere.com> wrote in message
                            news:8eednUBv4I 73iDPdRVn-uw@comcast.com. ..[color=blue]
                            >
                            > "Allan Bruce" <allanmb@TAKEAW AYf2s.com> wrote in message
                            > news:c8kte3$473 $1@news.freedom 2surf.net...[color=green][color=darkred]
                            > > > Thanks.
                            > > >
                            > > > As I asked Nevyn, would you use OOP if you were writing a program to[/color][/color][/color]
                            do[color=blue][color=green]
                            > > some[color=darkred]
                            > > > number crunching, e.g. solving a differential equation etc.?
                            > > >
                            > > > Pmb
                            > > >
                            > > >[/color]
                            > >
                            > > It entirely depends!
                            > >
                            > > I would use OOP if it were part of a bigger project, no two ways about[/color][/color]
                            it.[color=blue][color=green]
                            > > For example, one class may be a solver for differenial equations. One[/color]
                            > could[color=green]
                            > > 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![/color]
                            >
                            > 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.
                            >[color=green]
                            > >
                            > > 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[/color]
                            > scale,[color=green]
                            > > 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.[/color]
                            >
                            > and if you were someone like me who didn't have Matlab?
                            >
                            > Thanks
                            >
                            > Pmb
                            >
                            >[/color]

                            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


                            Comment

                            • G. Morgen

                              #15
                              Re: oops [was: Re: Object Oriented Programming (OOP)]

                              > I suggest another name: OOPS[color=blue]
                              > Object Oriented Ploughramming Swine[/color]

                              Progscriptum: No personal offence meant

                              Comment

                              Working...