Hi all, Can anyone explain me what is the difference between procedural programming and Object-Oriented programming. If possible tell me the good link where I can see these two things. Any help would be appreciated.
Thanx in advance
Nigel Browne
Ranch Hand
Joined: May 15, 2001
Posts: 673
posted
0
This is my attempt at summarising the main differences: Procedural Langauages Data and Process are separated Program components are abstractions of the real world Programs are difficult to maintain the larger they become There is very little reuse of earlier programs
Object-Oriented Objects consist of Attributes (Data) and Behaviour (Process) Program components try to model the real world Programs are easier to maintain Objects promote reuse of exisiting code through inheritance
This topic is huge and has probably been discussed before. Use the search tool or google to find out more detail
Jason Fox
Ranch Hand
Joined: Jan 22, 2004
Posts: 114
posted
0
Well, here's my $.02.
Object Oriented can mean many things, chiefly one of two: 1. The style supports Objects in some sense 2. The style uses/supports object-oriented ideas (encapsulation, inheritance, etc., etc.)
A procedural style to me means simply a more simple top-down sort of affair. Notice, I said style, not language. Although some languages (Java comes to mind) support an OO approach, its up to the programmer to use or ignore as much or as little as you'd like. I have seen procedural-style java and OO-style c. I have even heard rumors of object-oriented Assembler, though I have never done it nor seen it.
ppavya india
Greenhorn
Joined: Sep 27, 2004
Posts: 19
posted
0
Thanx folks.
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
posted
0
Moving this to the OO, Patterns, UML and Refactoring forum...
Hello ppavya ppavya I am a the local preceduarl extremest who likes to hangout in this forum . I will try not to talk too much of the benefits and flexibility of procedural programming and how I can move function to and from modules in less time then it takes to hold my breath. Functionality and data are separated, makes it easier to reuse code. One of the bad consequences of Object Oriented design is functionality seems to only belong to one data type and inheritances only create fragile tree structures.
Many people think that C and Pascal are the best procedural programming has to offer, but everybody knows the limitation with these languages, these limitation are not the inherent limitation with procedural programming.
Procedural design builds code that acts upon data structures. In my early days we ran "batch trails", dozens of COBOL programs one after another. One applied incoming paymnents to the master file. Another read the master file and made a list of accounts that were due for billing. Another read the list that needed billing and created bills. Each one read the data, performed some procedure and wrote the data. A top down divide and conquer or functional decomposition design style broke big jobs into lots of smaller jobs.
Later in online systems we had a series of screens for interactive use. Each screen had a program (or several) to read data from disk, present it on the screen, read it back from screen, manipulate it, write it back to disk.
In both cases, the number of programs that know and touch the master file record could be pretty big. A change to the record layout required a minimum of compiling and testing everything and at worst extensive changes to every program. Finding corrupt data at the end of the trail could mean tracing things backwards through program after program to find what changed and broke it.
OO seeks to focus on the behavior and hide the data structure. If I have an Account object I can ask it if it is due for billing without knowing anything about the data structure or how it decides when it's due. I can gather all the code that knows and touches the data in one place. "Information hiding" was a great concept in the structured world, and it's multiplied in OO.
Quite often when we introduce good structured programmers to OO they nod their heads and say "I knew that" or "I could do that with good module design." And they're absolutely right. In some ways OO is just another way of organizing code. But in some ways it turns your thinking completely inside out. When structured folk get to that point they smile big and start digging in to learn more.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Marlene Miller
Ranch Hand
Joined: Mar 05, 2003
Posts: 1391
posted
0
Can anyone explain me what is the difference between procedural programming and Object-Oriented programming.
When designing a complex software system, we decompose it into smaller parts.
In procedural programming, we decompose the system into steps and sub-steps in some overall process.
//Global data module struct A { int x; }; //data type definition struct B { int y; }; A a; //data is allocated B b;
In object-oriented programming, we decompose the system according to the key abstractions of the problem domain.
class ConceptA { int x; //data is allocated void compute() {...} //function definition void output() {...} }
class ConceptB { int y; void compute(ConceptA a) {...} void output(ConceptA a) {...} }
class Program { public static void main(String[] args) { ConceptA a = new ConceptA(); a.compute(); a.output(); }}
In procedural programming, control is centralized. One procedure gets data from other procedures and computes. In object-oriented programming, control is distributed. If object A is computing and object B has the data, instead of asking B for the data, object A gives control to object B.
In procedural programming, the system is viewed as a process. Procedures are steps and sub-steps in the process. In object-oriented programming, the system is viewed as a set of autonomous agents that collaborate to perform some higher level behavior. [ November 28, 2004: Message edited by: Marlene Miller ]
Marlene Miller
Ranch Hand
Joined: Mar 05, 2003
Posts: 1391
posted
0
Hi ppavya ppavya. Another programming paradigm is functional programming.http://www.htdp.org/ [ November 28, 2004: Message edited by: Marlene Miller ]