Object-oriented programming (OOP) is a programming paradigm that uses objects, which are instances of classes, to organize code. The OOP paradigm is based on several key features that facilitate the design, implementation, and maintenance of software systems.
The main features of the Object-Oriented Paradigm:
- Definition: Objects are instances of classes and represent real-world entities or concepts.
- Characteristics: Each object has attributes (data) and behaviors (methods/ functions).
- Definition: Classes are blueprints or templates that define the structure and behavior of objects.
- Characteristics: A class encapsulates data and methods that operate on that data.
- Definition: Encapsulation is the bundling of data (attributes) and methods that operate on the data into a single unit (class).
- Purpose: It hides the internal details of an object and restricts access to only what is necessary.
- Definition: Abstraction involves simplifying complex systems by modeling classes based on essential properties and behaviors, ignoring unnecessary details.
- Purpose: It focuses on what an object does rather than how it does it, providing a clear and abstract representation.
- Definition: Inheritance allows a new class (subclass or derived class) to inherit attributes and behaviors from an existing class (base class or parent class).
- Purpose: It promotes code reuse, extensibility, and the creation of a hierarchy of classes.
- Definition: Polymorphism allows objects of different types to be treated as objects of a common type.
- Types: Compile-time polymorphism (method overloading) and runtime polymorphism (method overriding).
- Purpose: It enhances flexibility, allowing a single interface to represent multiple underlying forms.
7. Message Passing:
- Definition: Objects communicate and interact by sending and receiving messages.
- Purpose: Enables collaboration between objects, facilitating the execution of methods and the exchange of information.
8. Dynamic Binding:
- Definition: Dynamic binding allows the association between a method call and the method implementation to be resolved at runtime.
- Purpose: Enhances flexibility and enables late binding, where the specific method to be executed is determined during program execution.
- Definition: Association represents a relationship between two or more objects.
- Types: Aggregation (weaker association) and Composition (stronger association).