Question:
why object oriented programming is developed?
2009-02-18 10:15:25 UTC
why do we need OOP? why cant we just stick with procedural programming? what is so good about it? 10points for best and clear answer. thanks
Nine answers:
2009-02-18 10:52:17 UTC
Emphasis is on data rather than things

Programs are divided in to what are known as objects.

Data structures are designed such that they characterize the objects

Data is hidden and cannot be accessed by external functions

Objects may communicate with each other through functions

Follows bottom up approach.



Disadvantages of procedural programs:

Global data are more vulnerable to an inadvertent change by a function.

In a large program it is very difficult to identify which data is used by which function.

It does not model real world problems very well.



Advantages of OOP

Supports polymorphism,Dynamic binding and Message Passing
question asker
2009-02-18 14:42:49 UTC
It allows sub-programs to interact with other parts of an application without the need for global variables. For me this is the main advantage of OO programming.



The other big advantage is the ability to create a class that inherits the properties of a class that someone else developed (e.g. an API class) and add your own functionality to it.



A good example of this was for a program I am working on (in java). I needed a JTextArea for displaying a programs output while it was running. But the problem I was having was that when you append text to a JTextArea it stays scrolled to the top of the window. This was a problem because I needed it to stay scrolled to the bottom as more text was added. The solution was to extend the functionality of JTextArea:



import javax.swing.JTextArea;



class myJTextArea extends JTextArea {



public void append(String text) {



// call the append function of the super-class..

// so it can do all the normal JTextArea append

// stuff:



super.append(text);



// this is my own addition to the JTextArea append

// function. It simply forces the Caret to the bottom of the text..

// If there is more text than can fill the window

// it also forces it to scroll to the bottom:



this.setCaretPosition(

this.getDocument().getLength()-1);

}

}





By extending JTextArea and over-riding it's 'append(String)' function I can treat it just like a normal JTextArea.. but with the addition of my own required behavior. And all it took was just a few lines of code.
2009-02-18 10:50:08 UTC
simple googling or wikipedia search will get you the answers.



The question you have asked is really a nice one and has even been debated over. But now a days its just another boring theoretical question that appears in examinations and irritates us.



well coming back to point:- in simple words the concepts which form the basis of OOPs, namely data abstraction, data encapsulation , polymorphism, inheritance etc, emphasise on the data the programmer has to work with, rather than the method that is to be used for solving the problem.



This method makes the process of code management easier. And hence eases the life of programmer. If you are in your early stages of studying computer science then lemme tell you that the professional software developers do not develop those stupid programs that we students develop in our programming labs.

Hundreds and thousands of lines of codes are written. It is then that the operating system you are working on , or the office suite you are using comes into existence. And when it comes to improving or managing those codes it becomes highly difficult to make sense out of it if the code follows procedural approach.

where as this is not the scenario with OOPs, as you will come to higher levels, and develop projects, you will yourself come to know what OOP has to offer and what havoc procedural programming creates.



Despite of my hatred towards such theoretical questions (which i dont even feel like to attempt in examination) I typed a fortune here.

I am amazed with my self.



do go to wikipedia link is provided below:-
2009-02-18 10:23:34 UTC
My understanding of this is that with OOP you can see your changes right away, but with procedural programming you have to build a complete working copy before you can view and see what you have done. I could be wrong, but you should google "OOP vs procedural".
candance
2016-10-06 13:51:48 UTC
merchandise-oriented programming (OOP) is a programming language form prepared around "gadgets" somewhat than "strikes" and documents somewhat than good judgment. traditionally, a application has been considered as a logical technique that takes enter documents, tactics it, and produces output documents. The programming undertaking replaced into considered as the thank you to jot down the best judgment, no longer the thank you to discover the advice. merchandise-oriented programming takes the view that what we actually care approximately are the gadgets we'd opt to manage somewhat than the best judgment required to manage them. Examples of gadgets variety from people (defined via call, handle, etc) to homes and flooring (whose properties could be defined and controlled) right down to the little widgets on your computing gadget laptop (alongside with buttons and scroll bars).
Ryan J
2009-02-18 10:51:28 UTC
OOP lends itself to better facilities for reusable code and reusable code could probably best explained by Design Patterns (ie: Class Factory, MVC, MonoClass, Singleton, etc).



Here's a good book that's easy to understand and the examples are in Java



http://www.amazon.com/First-Design-Patterns-Elisabeth-Freeman/dp/0596007124



The design patterns book known by all programmers is the one by the Gang of Four (gof)



http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612/ref=sr_1_1?ie=UTF8&s=books&qid=1234982932&sr=1-1



Also, a pure object oriented language (C#, Java, Etc.) is often easier to understand and develop with rather than a hybrid language (C++).
ManOfTheHour
2009-02-18 10:27:10 UTC
OOP more easily facilitates reuse and maintenance. Also, inheritance capabilities allow for easy extension of functionality.
Monroe C
2009-02-18 10:24:58 UTC
The main advantage is the use on class inheritance and overriding. (Building on existing code)
Jessie_Kaylee
2009-02-18 10:27:00 UTC
go here


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...