Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Procedural Vs OOP

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx folks.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the OO, Patterns, UML and Refactoring forum...
 
Ranch Hand
Posts: 872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

I have found a JavaWorld link that explains a little better how procedural programming can promote code reuse. http://www.javaworld.com/javaworld/javatips/jw-javatip107.html
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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;

//Main module
void Program()
{
initialize(); //function calls
doInputStep();
doComputeStep();
doOutputStep();
}

//Input module
void doInputStep() {...} //function definition

//Processing module
void doComputeStep() //function definition
{
doPart1(); //function calls
doPart2();
doPart3();
}
void doPart1() {...} //function definitions
void doPart2() {...}
void doPart3() {...}

//Output module
void doOutputStep() {...} //function definition

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
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ppavya ppavya. Another programming paradigm is functional programming.http://www.htdp.org/
[ November 28, 2004: Message edited by: Marlene Miller ]
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"ppavya ppavya"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark
 
    Bookmark Topic Watch Topic
  • New Topic