Monday, January 17, 2022

Difference between Procedure Oriented Programming System and Object Oriented Programming System (POPS vs OOPS)

POPS vs OOPS 

Today we will get to know the difference between Procedure oriented Programming system (POPS) and Object-Oriented Programming System (OOPS). 

In languages like C which is called as Procedure Oriented Programming language, a programmer writes a function or procedure to perform a task. 

When a programmer is assigned to implement a task in C language, he will first divide the task into multiple subtasks and for each subtask he will write a function. 

 

Say for example there is task assigned with a task 

  • To login the user into internet banking application 
  • To update the profile  
  • Transfer the funds from his own bank account to another bank account  
  • Logout. 

To implement this task in C language, 

User will create methods  

  • Method for login 
  • Method for update profile 
  • Method to transfer funds from one account to other account 
  • Method to withdraw funds from his own account 
  • Method to deposit funds into the beneficiary account 
  • Method to logout

 

And he will call all of these methods one after the other or based on user interaction from main method 

Here everything is being achieved by methods or functions or procedures. 

Problems with Procedure oriented programming approach 

  • Concentration is on methods or operations not on data.  
  • Write new methods for any new task comes-in. 
  • Code reusability is very less, that can be done by calling the methods. 
  • If codebase becomes large, hard to debug or read or maintain. Because we will not able to track which method is written for what purpose. 
  • Difficult to relate with real world entities. 

Real world entities for example an animal, vehicle, insurance policy, bank transaction etc. These entities will have some properties and they will perform some action to it. In this system when we write programs for these entities, as we write everything in functions, it is  difficult to relate the functions with real world objects. 

  • Data is exposed to the whole program, you cannot limit the visibility of data or operation.  

There are no security constructs available to limit the visibility of data. 

 

If the same task is assigned to a programmer who knows the Object Oriented Programming approach, then he will divide each of these subtasks into separate classes. 

 

 

  • Class for login and logout 
  • Class for all profile update operations 
  • Class for all transactions. 

Each class will be having data that is required for the objects and methods those acts on the data 

The classes can be reused or the functionality of methods can be extended via Inheritance 

Advantages of OOPS 

  • Concentration is on data 

  • Write new classes for the new functionality comes-in 

  • Code reusability is achieved via inheritance.  

  • Easy to maintain or debug even if the code base grows big, because code is modularized based on classes. 

  • Easy to relate with real world entities. 

  • Secure or limited access of data that resides in objects of a class can be given to other classes. 

 

Difference between Procedure Oriented Programming System and Object Oriented Programming System (POPS vs OOPS)

POPS vs OOPS   Today we will get to know the difference between Procedure oriented Programming system (POPS) and  Object-Oriented  Programmi...