Friday, July 31, 2009

What is the difference between procedural and object orientated programming?

As I understand it, or rather don't, the basic premise of object orientated programming is that components of source code are reusable.





Surely this is also the case with procedures, as that same chunk of code can be used ad infinitum?





Please do be concise but avoid overly technical jargon. Thanks.

What is the difference between procedural and object orientated programming?
You are right on both counts. Both OO and procedural can be reused if well written.








I've been programming for 5 years, and I learned by object oriented programming, so I can't imagine doing it any other way.








And I'm not gonna pretend to be able to give you a good answer on this topic in such a short space. But I will forward you some links.





This is a good article on the subject:





http://devzone.zend.com/node/view/id/123...
Reply:Object-oriented programming (OOP) is a programming paradigm that uses "objects" and their interactions to design applications and computer programs.





Procedural programming is sometimes used as a synonym for imperative programming (specifying the steps the program must take to reach the desired state), but can also refer (as in this article) to a programming paradigm based upon the concept of the procedure call.
Reply:Both can be reused in code, but object oriented programming makes it a lot easier.





Procedural program provides the methodology to state how to perform a set of work on data. This relies on the fact that every procedure in your program uses the data the same way and cooperates. If this is true for your program and everyone that uses the program then a high rate of re-use can be achieved.





Object oriented programming languages encapsulate the data and the procedures together as a tight unit. Since the object data for the object is only used by procedures (functions, methods) of the object a high amount of data understanding is ensured and the entire module data and function can be re-used.





As a metaphor, you want to fill out a tax return. In a procedural language you would create the logic for how to fill out a tax return, then later you would give that procedure data and hope that it is for the correct state. In an object oriented language you could not make this mistake since the logic for a tax return and the data for that tax return are bonded together. The rules for how to fill out a tax return are in the same envelope as the instructions.
Reply:I think the point is that you can have many


instances of an object, which is only coded


once. The example I can give you is I wrote


an algebra engine in C which needed to be


invoked several times and in C I had to make


several passes and then hd to go through a


"consolidation" process. When I translated


to C++ every time I wanted an instance I would


just "new" the object and each instance would


work concurrently.

flower names

No comments:

Post a Comment