Object-Oriented Programming
The Four Pillars of OOP
Object-Oriented Programming (OOP) is a programming paradigm based on the concept of
"objects," which can contain data (attributes/properties) and code (methods/functions). It is
designed to make code more reusable, scalable, and easier to maintain.
• Encapsulation: The bundling of data with the methods that operate on that data
into a single unit (a class). It restricts direct access to some of an object's
components, which is a means of preventing accidental interference and misuse
(data hiding).
• Abstraction: Hiding the complex, internal implementation details of an object and
exposing only the necessary, relevant parts to the user. It simplifies interaction by
providing a clear interface.
• Inheritance: A mechanism where a new class (child or derived class) inherits
properties and behaviors from an existing class (parent or base class). This
promotes code reusability and establishes a logical hierarchy.
• Polymorphism: The ability of different classes to be treated as instances of the
same class through a common interface. It allows methods to do different things
based on the object it is acting upon (e.g., method overriding and overloading),
making systems more flexible.