Articles

OOP vs POP programming model

OOP vs POP programming model


Object oriented programming has emerged as a highly efficient way of programming for the real world, as opposed to procedural oriented programming where one focused on code rather than on the real world problem.The title itself, ‘Object Oriented Programming’ suggests us about its working; it is ofcourse focused around an object, and all the concepts are designed in such a way that the program itself returns to the ‘objects’ of the problem.
 
To understand object oriented programming, we refer to a real world problem and its solution in OOP and POP.
 
For example, we are to make a program where we take the measurements of a wall, let the user choose the type of paint and tell them the cost of painting that wall, including the painter’s charges.
 
Procedural Oriented Programming
If we were to solve this problem in a POP way, we would have focused on how to calculate the area, how to add the charges, and to display the result. One of the POP languages is C. Let us see how the code would look like in C.
 
#include<stdio.h>

OUTPUT
 
The Cost of painting a wall with measurements : 
Height : 7.00 
Breadth : 9.00 
and paint of type 2 is Rs. 804.00
 
 
Here, input is given in the main function itself for brevity. Here we do not focus any object, but only on the calculation.
 
Object Oriented programming : - If we are to solve the above problem in POP way, we would have to focus on the Object rather than on the calculation. There could be many ways of thinking of a particular problem,one of them is thinking that the object could be the wall,having variables the height and breadth. C++ being an Object Oriented Programming language, lets have a look at the solution in C++.
 
#include<iostream>
OUTPUT
The Cost of painting a wall with measurements : 
Height : 7
Breadth : 9
and paint of type 8 is Rs. 804
 
In the above program , we focus on the wall as an object and operate all the values as the calculations related to the object. In the main function, we create an object of the class Wall and call  method show from it. Here again input is provided in the program itself and not taken from the user for the sake of brevity.

This article was submitted by:

Name: Prabjot Kaur
Studying:  MCA 
College: RCC Institute of Information Technology,Beliaghata,West Bengal.



Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com

About the Author
Prabjot Kaur
Page Views :    Published Date : Jun 28,2020  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!