by Dinesh Thakur

Now that we know the basic concepts in OOP, we are in a position to compare it with classical procedure oriented programming.

In classical procedural (or structural) programming, there are techniques to write a code that handles some general task The most important techniques of that kind are functions (procedures or sub-routines). The large program is partitioned into functions that each perform a specific task. The main program calls these functions, which in turn may call other functions. The major concern of this programming is with respect to the data.

Data are passed around from one non-member function to another and are available everywhere throughout the large program. This allows the user to access the data directly, alter it from several points in the program and inadvertently introduce mistakes. If one programmer changes the representation of the data in the computer's memory by rearranging fields within a structure (record), other functions in the program may need to be rewritten and must then be retested to account for this change. That means the data are not well protected in procedure oriented programming. Though local variables in a function can be accessed within the function, they are not useful if they must be accessed by different functions.

In contrast, OOP safely encapsulates collections of functions (called methods) with the data they manipulate. In other words, the data can only be manipulated by its own functions. This feature protects the data from rest of the program.

Though the concepts of object oriented programming are different from procedural oriented programming, structured programming constructs are still used in OOP especially in the coding of methods .