Unit 5: Object-Oriented Programming (OOP) Concepts
OOP vs POP paradigm comparison, core principles of Object-Oriented Programming: classes, objects, encapsulation, abstraction, inheritance, and polymorphism.
1. Procedure-Oriented Programming (POP) vs OOP
| Feature | Procedure-Oriented (POP) | Object-Oriented (OOP) |
|---|---|---|
| Core Focus | Focuses on functions, procedures, and algorithm logic. | Focuses on data, state, and real-world objects. |
| Program Structure | Divided into small functions/procedures. | Divided into classes and objects. |
| Approach | Top-down design approach. | Bottom-up design approach. |
| Data Security | Low security; global data moves freely between functions. | High security; data is encapsulated and hidden from unauthorized access. |
| Code Reusability | Limited code reusability. | High reusability through inheritance. |
| Examples | C, Pascal, FORTRAN, BASIC | C++, Java, Python, C#, PHP |
2. Fundamental Features & Principles of OOP
- Class: A user-defined data type and blueprint/template defining attributes (data members) and behaviors (member functions).
- Object: A basic runtime instance of a class that possesses state, behavior, and identity.
- Encapsulation: The bundling of data and the functions that manipulate that data into a single unit (class), hiding internal details from external misuse.
- Abstraction: Representing essential features of an object without including background implementation complexity.
- Inheritance: The mechanism by which a child (derived) class acquires properties and behaviors from a parent (base) class, promoting code reusability.
- Polymorphism: The ability of a message, function, or operator to take more than one form (e.g. Method Overloading, Method Overriding).