Programs are  written to recreate real world scenarios and entities. And as we know, the world is made up of objects interacting with each other. Thus, for a program to be able to represent the real world more accurately, it has to know how to work with objects.

In normal language, objects are defined as physical items that you can interact with, tangible and intangible. For example, a car is an object, you can see it,  touch it, make it move, etc. Object oriented programming(OOP) utilizes this understanding of physical objects in order to simulate real world scenarios and interactions more accurately.

In object oriented programming, objects are logical entities created to represent real-world concepts. The same concepts that are reflected in physical objects are also reflected in software objects.  Software objects have properties and behaviors, allowing them to represent real-world concepts in an organized and more accurate manner.

OOP is a programming paradigm  that organizes program data around the concept of objects rather than functions and logic. In this paradigm, statements are grouped into self-contained entities(objects) that can interact with other parts of the program as one. 

OOP terms and Definitions

The following terms are relevant in the context of OOP .

  • Object -  Objects are entities that contain data in the form of attributes,  and behaviors in form of methods. They are the basic unit of object oriented programming.
  • class -   A class is an extensible blueprint/template for creating objects. Classes provide the  initial values  and implements the behaviors that are shared by the objects.
  • property -  A property is a value associated with a particular object. Properties are also known as the data members.
  • method -  A method is a function associated with a class or object. Methods are usually used to manipulate the properties associated with the class and its objects. They are also known as the behaviors.
  • Constructor -  A constructor is a special method used to initialize an object's state when it is first created. It is called automatically when an object is being instantiated. Constructors may accept arguments that can be used to set initial values for the object.
  • Encapsulation Encapsulation is a way of shielding the data and behavior of an object from outside access. It ensures that some data can only be accessed and modified from within the object.
  • Abstraction -  Abstraction is a process of isolating or hiding the details of an object or system by concentrating on its features or behaviors without any implementation details. 
  • Inheritance - Inheritance is a technique that allows a class (child class) to inherit property from another class (parent class). This creates an “is-a” relationship between the two classes, which means that the child class is a type of the parent class. This allows for code reuse making it possible to build new classes from existing ones.
  • Child class  -   A child class is a class that inherits properties and methods from another class(parent class). It can then add additional features, making it a specialized version of the parent class. A child class is also referred to as a subclass or a derived class.
  • Parent class - A parent class is a class from which other classes are derived. The parent class provides the basic structure and functionality that other classes inherit and extend. The parent class is also referred to as super class or base class.
  • Method overriding -  Method overriding  allows a child class to provide a different implementation of a method that is already defined by one of its super classes. 
  • Polymorphism -  Polymorphism refers to the ability of an object to take on multiple forms. It allows objects of different types to be treated the same way, meaning that the same code can work on objects of varying types. 

Advantages of OOP

OOP has a lot of advantages over the traditional programming paradigms.  It facilitates the ability to model real world objects more precisely as the code is organized into cohesive, logical chunks. Some advantages of OOP includes:

  1. Enables real world modeling -  OOP allows developers to represent real-world objects and their behaviors in code. Through OOP, we can create objects that have properties and methods that reflect a real-world object’s characteristics and behavior. This makes it easier to create applications and simulations that accurately reflect real-world objects and their interactions. For example we can model a car object that  has properties and behaviors just like a car in real life. 
  2. Promotes code reuse - Through inheritance a subclasses acquires all the methods and properties defined in the superclass. This allows the subclass to reuse the code and data of the superclass without having to redefine it from scratch.
  3. Improves Maintainability -  OOP helps to improve maintainability by encouraging the creation of self-contained objects. Such objects are  loosely coupled meaning that changes to one object will not directly impact other objects. This helps to keep code organized and makes it easier to debug and modify the application thus improving maintainability.
  4. Improves Extensibility -   OOP promotes decoupling between the various components allowing individual elements to be modified without impacting other parts of the system. This makes it easier to add new features without losing existing functionality.
  5. Data hiding -  Data hiding is a technique of preventing the data in an object from being unintentionally altered by external parts of the program. Keeping the data contained within the object enables it to maintain its integrity and ensures that changes are only made when the programmer intends to make them.