web analytics

“POP provides emphasis on doing things, but OOP on the data”─ Do you agree with this statement? Justify your answer.

“POP provides emphasis on doing things, but OOP on the data”

Yes, I agree with the given statement, “POP provides emphasis on doing things, but OOP on the data”.

Justification of acceptance

In the case of a large program created using the concept of Procedure Oriented Programming, sometimes we declare some Global Variables which will be used by all the functions of the program. As we know that variable generally defines memory locations, thus in the case of a global variable,

a single memory location will be used by many functions. For example, a function may bring change to a global variable where it was in need to stay unchanged by another function. So, data stored under such kind variable are not safe or protected and can ruin a whole program. So POP is not emphasizing on data. It creates functions which use data.

On the other hand, Object Oriented Programming emphasizes on data. That is, OOP always ensures the protection of data. For explanation, considering the following lines of codes,

class Shared{
    // declaring two variables of this class
    int a, b;
    // declaring a function to put values of a and b
    void set(int i, int j){
        a=i; // setting a
        b=j; // setting b
        }
    };

Here we have a class named Shared and two variables a and b and a function void set(int i, int j). This function is setting the values of i and j to a and b respectively. Now let us declare objects and call the function,

void main(){
    Shared x, y;     // declaring x and y as two Shared class type object
    x.set(1,5);      // calling set() function of Shared class to use on x
    y.set(10,11);    // calling set() function of Shared class to use on y
    }

From here we can find that x.set(1,5) statement will use the class, function and the variables a and b and will store 1 under a and 5 under b. The next statement y.set(10,11) will again use the class, function and same variables a and b and will store 10 under a and 11 under b. But a single variable can’t contain two values, thus here in OOP to secure data for each object, when executing creating two memory locations for a and b under x object and then again creating another two memory locations for a and b under y object. That’s how OOP emphasizes on and secures data.

Read More: Differences between OOP and POP?

Scroll to Top