Procedure Oriented Programming vs Object Oriented Programming.
The shift from Procedure Oriented Programming (POP) to Object Oriented Programming (OOP) was motivated by the need to address the increasing complexity of software systems and the inherent flaws in conventional programming methods. C++ was developed to explicitly support the OOP paradigm, combining it with the capabilities of C.
Here is a comparison between Procedure Oriented Programming and Object Oriented Programming, based on fundamental principles and methodology:
Comparison of POP vs. OOP
| Characteristic | Procedure Oriented Programming (POP) | Object Oriented Programming (OOP) |
| Primary Emphasis | The primary emphasis is on doing things (algorithms). | The emphasis is on data rather than procedure. |
| Program Structure | Large programs are divided into smaller programs known as functions. | Programs are divided into entities known as objects. |
| Data Handling | Most functions share global data. Data moves openly around the system from function to function. | Data is treated as a critical element and is protected from accidental modification. Data is tied closely to the functions that operate on it. |
| Data Security | Data is vulnerable to inadvertent change by any function in the program. | Data is hidden and cannot be accessed by external functions (Data Hiding/Encapsulation). |
| Design Approach | Employs a top-down approach in program design. | Follows a bottom-up approach in program design. |
| Real-World Modeling | It does not model real-world problems very well because functions are action-oriented. | Allows decomposition into real-world objects, enabling programs to directly model or simulate their real-world counterparts. |
| Evolution and Change | Revising an external data structure requires revising all functions that access the data, often leading to bugs. | New data and functions can be easily added whenever necessary. OOP supports mechanisms like Inheritance for code reusability. |
| Communication | Functions transform data from one form to another. | Objects communicate with each other through functions (message passing). |
OOP as a Solution to POP Flaws
OOP was invented explicitly to overcome the drawbacks of POP. While POP focuses on writing a sequence of instructions and organizing them into functions, leading to issues where core data items are placed globally and are vulnerable, OOP organizes data and functions around entities called objects. This approach allows for partitioned memory areas for both data and functions, providing insulation for data, a key feature known as data encapsulation. OOP enables programmers to build robust programs with clarity, extensibility, and ease of maintenance.
The core principles that characterize OOP and provide these advantages are: Objects, Classes, Data Abstraction, Encapsulation, Inheritance, Polymorphism, Dynamic Binding, and Message Passing.