Procedural Programming.
Procedural Programming is a programming paradigm that revolves around a step-by-step approach to solving problems by executing procedures or routines. In this paradigm, the emphasis is on procedures or functions that manipulate data, sequentially performing specific tasks. Languages that use procedural programming are C, Pascal, FORTRAN, BASIC, COBOL, and ALGOL.Key Characteristics of Procedural Programming.
- It focuses on breaking a program into smaller, reusable functions or procedures.
- Procedural programming often utilizes global variables that can be accessed from anywhere in the program.
- Problem-solving follows a top-down methodology, where the main task is broken into smaller sub-tasks.
- Procedural programming code tends to be less reusable compared to Object-Oriented Programming.
Object-Oriented Programming.
Key Characteristics of Object Oriented Programming.
- Objects are instances of classes, which serve as blueprints defining the structure and behavior of objects.
- In OOPs, encapsulation hides the internal state of an object and exposes only necessary functionalities through well-defined interfaces.
- In OOPs, we have an inheritance property that enables new classes to inherit attributes and behaviors from existing classes, promoting code reuse and hierarchy.
Procedural Programming Vs Object Oriented Programming.
| Procedural Programming | Object-Oriented Programming |
|---|---|
| Procedural Programming focuses on sequential execution via functions or procedures. | Object-Oriented Programming (OOP) focuses on objects and their interactions. |
| Procedural Programming follows a top-down approach to code execution. | Object-oriented follow bottom-up approach for code execution. |
| The program often relies on global data access. | The program uses encapsulation to restrict data access. |
| Less emphasis on code reusability. | Promotes code reusability through inheritance and abstraction. |
| Procedural Programming has no inherent concept of hierarchy. | Object-Oriented uses inheritance to create hierarchies and relationships. |
| Code may become more complex as program size grows. | OOP handles complexity better, suitable for larger and complex implementation details. |
| Example: C, COBOL, FORTRAN, BASIC | Example: C++, Java, Python, C#, Ruby |

