Procedural vs. Object Oriented Programming

  • By reComparison Contributor
  • comments 0
  • views26991

Difference between Procedural Programming and Object Oriented Programming

Procedural and Object Oriented are the two most popular programming paradigms. Procedure is another name for a routine, method or function. Procedural programming refers to calling of a function whenever required. Functions are separated from variables and data structures. Object oriented programming paradigm, on the other hand, merges the data with the function and this function changes the data that is bound to it in an entity called an object. Various useful features such as abstraction, encapsulation and inheritance can be achieved while working with Object Oriented approach.

Procedural Programming
Object Oriented Programming

Paradigm

A procedure is a sequence of instructions that are grouped together. These are executed one by one when procedure is called. In such a technique the programmer divides his program in three parts viz. Variables, data structures and routines. In a procedural approach, the entity called a variable is termed as an attribute of the object in an object oriented paradigm. The idea is to encapsulate data and method into a class. Class is a prototype. One can make any number of objects hence code becomes reusable.

Performance

Object oriented programming has been observed to give a lower quality performance as compared to procedural programming. But this is not enough to conclude that procedural approach is the best one to follow. As in case of C++ and C, although C is faster, still more effective effort in needed to build program in C as compared to using C++. Sometimes the performance increases due to features in object approach such as encapsulation, abstraction, polymorphism and inheritance. LOC (line of code) in case of object oriented turn out to be much less due to code re-usability.

Features

Procedural programming provides modularity. Input values for a function to work with are provided in the form of arguments and the returned value is the output. A procedure can only access the variables in its scope hence coming up with the feature called scoping. A procedure is an independent entity and can be put to use by different programmers in their entirely different codes. Object oriented programming provides encapsulation making a class whose objects can be created dynamically. It provides object inheritance. Again class provides modularity – a much desired feature. Some other features that might interest you as a programmer are polymorphism, abstraction and open recursion.      

Summary

Procedural Programming

  • Procedural programming refers to calling of a function whenever required.
  • A procedure is a sequence of instructions that are grouped together.
  • Program is divided into three parts: Variables, data structures and routines.
  • Procedural programming provides modularity and scoping.
  • Although programs written with procedural approach are fast and consume less space but object oriented approach provides important features that make programming efficient. 

Object Oriented Programming

  • Object oriented programming paradigm merges the data with the function and this function changes the data that is bound to it in an entity called an object.
  • This property of combining attributes, data structures and methods in a class is called encapsulation.
  • Class is a prototype whose objects can be created dynamically.
  • Polymorphism, abstraction, inheritance, open recursion, encapsulation and modularity are some important features of object oriented programming.

Comparison of Procedural and Object Oriented Programming

Which is the best for the job?
  • Procedural Programming
  • Object Oriented Programming
 
 

Discuss It: comments

Post a Comment
  • Name*
  • Email*
  • Website (optional)
  • arrow You are commenting as a Guest
  • arrow Your email will not be public
  • arrow Login or Sign Up and post using your reComparison account
  • arrow Facebook Connect