Difference between Procedure Oriented and OOP
- Definition:
- Procedure-Oriented Programming (POP):
- Focuses on writing procedures or functions to perform tasks.
- Object-Oriented Programming (OOP):
- Focuses on creating objects that contain both data and methods.
- Data and Functionality:
- POP:
- Data and functions are separate and independent entities.
- OOP:
- Data and functionality are encapsulated together within objects.
- Encapsulation:
- POP:
- Does not emphasize encapsulation.
- Data can be accessed and modified directly by any part of the program.
- OOP:
- Emphasizes encapsulation, bundling data and methods together within objects.
- Access to data is controlled through methods, promoting data integrity and hiding implementation details.
- Abstraction:
- POP:
- Limited support for abstraction.
- Functions may abstract certain operations, but data structures and algorithms are often exposed.
- OOP:
- Strong support for abstraction.
- Classes define abstract data types, allowing complex systems to be modeled at higher levels of abstraction.
- Inheritance:
- POP:
- Does not support inheritance.
- Code reuse is typically achieved through function libraries or by copying and pasting code.
- OOP:
- Supports inheritance, allowing classes to inherit properties and behavior from parent classes.
- Polymorphism:
- POP:
- Polymorphism is limited or non-existent.
- OOP:
- Supports polymorphism, allowing objects of different classes to be treated uniformly through a common interface.
- Examples:
- POP:
- C programming language is often used as a procedural programming example.
- OOP:
- Languages like Java, C++, Python, and Ruby are commonly used for OOP.