9 Replies - 9960 Views - Last Post: 25 February 2010 - 11:58 AM Rate Topic: -----

#1 Guest_quest*


Reputation:

What's the purpose of Object Oriented Programming?

Posted 23 February 2010 - 07:42 PM

I'm trying to learn it and it's hard to find something if I don't have much of an idea of what it's used for. Can anyone explain what its pros and cons and what exactly its used for?
Is This A Good Question/Topic? 0

Replies To: What's the purpose of Object Oriented Programming?

#2 pdkharkar  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 63
  • View blog
  • Posts: 345
  • Joined: 19-January 09

Re: What's the purpose of Object Oriented Programming?

Posted 23 February 2010 - 07:50 PM

look
when object oriented programming was not invented then programmers used procedural programming methods
i.e. whole program was just one part and the sequential flow of the program was there
the programs were not so much readable and if there was some big problem to solve then programmers needed to code in a hectic way as no grouping facilities were there.
In object oriented programming, we can form groups of code for specific purpose, those are called as methods
and we can create the objects those are instances of the classes we have created. These objects can call the methods of respective classes
also
the object oriented programming concepts allow us to use some features like data encapsulation which allows us to protect our data from outer methods, concept of polymorphism which allows us to use same method name for different purposes and many features
If you want some more information about OOP then visitthis link
Was This Post Helpful? -4
  • +
  • -

#3 DaneAU  Icon User is offline

  • Great::Southern::Land
  • member icon

Reputation: 285
  • View blog
  • Posts: 1,619
  • Joined: 15-May 08

Re: What's the purpose of Object Oriented Programming?

Posted 23 February 2010 - 08:29 PM

The purpose is to Model Real World Objects and keep the descriptions and definitions of them specific to those objects. Allowing programs to incorporate many objects and instances of objects. There is definitely better descriptions than this, however thats how i have basically deduce my own definition of Object Oriented Programming.

This is a quote from wikipedia link

Quote

An object is actually a discrete bundle of functions and procedures, all relating to a particular real-world concept such as a bank account holder or hockey player in a computer game. Other pieces of software can access the object only by calling its functions and procedures that have been allowed to be called by outsiders. A large number of software engineers agree that isolating objects in this way makes their software easier to manage and keep track of. However, a not-insignificant number of engineers feel the reverse may be true: that software becomes more complex to maintain and document, or even to engineer from the start. The conditions under which OOP prevails over alternative techniques (and vice-versa) often remain unstated by either party, however, making rational discussion of the topic difficult, and often leading to "religious wars" over the matter.


It sums it up a fair bit better than i did.

This post has been edited by bbq: 23 February 2010 - 08:31 PM

Was This Post Helpful? 0
  • +
  • -

#4 Martyn.Rae  Icon User is offline

  • The programming dinosaur
  • member icon

Reputation: 540
  • View blog
  • Posts: 1,406
  • Joined: 22-August 09

Re: What's the purpose of Object Oriented Programming?

Posted 23 February 2010 - 10:06 PM

*
POPULAR

View Postpdkharkar, on 24 February 2010 - 01:50 AM, said:

look
when object oriented programming was not invented then programmers used procedural programming methods
i.e. whole program was just one part and the sequential flow of the program was there
the programs were not so much readable and if there was some big problem to solve then programmers needed to code in a hectic way as no grouping facilities were there.
In object oriented programming, we can form groups of code for specific purpose, those are called as methods
and we can create the objects those are instances of the classes we have created. These objects can call the methods of respective classes
also
the object oriented programming concepts allow us to use some features like data encapsulation which allows us to protect our data from outer methods, concept of polymorphism which allows us to use same method name for different purposes and many features
If you want some more information about OOP then visitthis link


@pdkharker - this is one of the biggest loads of garbage I have read in a long time. Do not discuss things that you have absolutely no idea about.

Let me introduce you to the world of procedural programming, where you will be surprised to learn that things like data encapsulation not only existed but were used extensively by those programmers who coded in a hectic way. In this world, where grouping factilites existed, and the whole program was written into managable chunks called sub-programs. Where grouping facilities and polymorphism existed for those who understood what it was and how to implement it. In fact the only feature in the current implementation of C++ that did not exist was operator overloading.

What C++ and object-oriented programming achieved was the ability to expressutilize all the things we had before, but in a more expressive manner through the language itself. Nothing more and nothing less.

You may be surprised to learn that your C++ programs, in all their glory are compiled into assembler (which is most certainly not an object-oriented language) and on into machine code. It is executed on a processor that performs instructions sequentially, calling subroutines just like it did when executing those one part, not so readable, hectic programs consisting of one part. In fact, most C++ compilers are not written in C++.

This post has been edited by Martyn.Rae: 24 February 2010 - 12:57 AM

Was This Post Helpful? 5
  • +
  • -

#5 pdkharkar  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 63
  • View blog
  • Posts: 345
  • Joined: 19-January 09

Re: What's the purpose of Object Oriented Programming?

Posted 23 February 2010 - 10:41 PM

@Martyn.Rae
Thank you for the information sir
I just posted according to my knowledge
well I am not an expert like you
I just tried to help to the best
Thank you for personally giving me the suggestion
and also... even you can punish me for wrong posts
I don't mind
I just want myself improved day by day!
really thank you for that!
I am clicking the "Green Plus Sign" :rolleyes:
Was This Post Helpful? 0
  • +
  • -

#6 PlasticineGuy  Icon User is offline

  • mov dword[esp+eax],0
  • member icon

Reputation: 281
  • View blog
  • Posts: 1,436
  • Joined: 03-January 10

Re: What's the purpose of Object Oriented Programming?

Posted 25 February 2010 - 01:45 AM

Quote

In fact, most C++ compilers are not written in C++.
Remember the distinction between compiler and IDE. I would rather pull off my big toenail than write a full IDE in pure ASM.
Was This Post Helpful? -1
  • +
  • -

#7 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5846
  • View blog
  • Posts: 12,705
  • Joined: 16-October 07

Re: What's the purpose of Object Oriented Programming?

Posted 25 February 2010 - 04:36 AM

View PostMartyn.Rae, on 23 February 2010 - 11:06 PM, said:

In fact the only feature in the current implementation of C++ that did not exist was operator overloading.


Aw, come on, there's more than that... ok, at least from C to C++, you're ultimately talking loads of syntax sugar. A fundamental element of all OOP languages is the implicit association of a procedure with a structure. e.g. "void add(List *list, int n)" v.s. "void List::add(int n)". For OPP in pure C, you can pull this off to some extent with function pointers; you always have to the "this." Curiously in C you can even pull off encapsulation, just using files rather than pure syntax.

This point is, agreeing with Martyn, the idea of OOP can be implemented in non OOP languages. Conversely, a strong OOP language like Java can be written completely procedurally ( the static, it burns.) Programming paradigms can be reinforced by language design, but are not exclusive to them. The languages come after the idea, after all.

Assembly is a language; without it you can program in machine code. Most assembler commands map one to one to machine commands. But there is some extra syntax there, like labels. An adept programmer can use procedural and even OO concepts in assembler. It just takes more effort.

View PostMartyn.Rae, on 23 February 2010 - 11:06 PM, said:

You may be surprised to learn that your C++ programs, in all their glory are compiled into assembler (which is most certainly not an object-oriented language) and on into machine code.


It's probably worth noting, most C++ implementations preprocess all that pretty C++ code down to C, then down to assembler.

Edit: one word, totally different meaning.

This post has been edited by baavgai: 25 February 2010 - 05:59 AM

Was This Post Helpful? 1
  • +
  • -

#8 Martyn.Rae  Icon User is offline

  • The programming dinosaur
  • member icon

Reputation: 540
  • View blog
  • Posts: 1,406
  • Joined: 22-August 09

Re: What's the purpose of Object Oriented Programming?

Posted 25 February 2010 - 08:53 AM

Quote

It's probably worth noting, most C++ implementations preprocess all that pretty C++ code down to C, then down to assembler.


Not my C++ compiler :bigsmile:
Was This Post Helpful? 0
  • +
  • -

#9 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5846
  • View blog
  • Posts: 12,705
  • Joined: 16-October 07

Re: What's the purpose of Object Oriented Programming?

Posted 25 February 2010 - 09:44 AM

View PostMartyn.Rae, on 25 February 2010 - 09:53 AM, said:

Quote

It's probably worth noting, most C++ implementations preprocess all that pretty C++ code down to C, then down to assembler.


Not my C++ compiler :bigsmile:


Really? I'm impressed. And more than a little incredulous.

What compiler?
Was This Post Helpful? 0
  • +
  • -

#10 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: What's the purpose of Object Oriented Programming?

Posted 25 February 2010 - 11:58 AM

OOP is just a way of approaching program design that tries to group both data and code into a single abstraction (called an "object") that "models" something.

So in OOP I might create a class "Bird" that models a bird for my application. The class might have several data members that describe the bird such as species, color, etc. Then it may have different methods that model how a bird might behave (within the context of what is being modeled) -- fly(), walk(), eat(), chirp() etc....

The purpose of OOP is to organize a program's structure so that one can build programs using these abstract models called "objects" that encapsulate data and behavior into one unit. This allows one to work with code that is a little more connected to the actual problem space and a little more abstracted from the computer-programming implementation details.

OOP is realized much more in Java or C# than it is in C++ as C++ still tends to require a good amount of concentration on the "implementation details".

It is an "abstraction paradigm" -- meaning simply that it is a way that we can look at programming that helps us build programs.

One does not need an Object Oriented language to implement OOP -- however, because OOP has rules and conventions that are much much easier to work with when it is a compiler that enforces things. i.e. you can write OOP in C (in fact some C++ compilers actually compile the program down to C rather than assembly or machine language), but you have to enforce all of the conventions yourself. Since this is a little tiresome (and humans always want to cheat) one generally uses an OOP language rather than trying to do it by hand. (I used to use some very pseudo-OOP programming conventions in QBasic because it made my programs easier to develop).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1