What is Object Oriented Programming?

Sep 26th, 2022


While reading articles and watching development videos, I came across a new term called Object Oriented Programming and decided to look into it. In this article, I will provide an introduction to Object Oriented Programming.

What is Object Oriented Programming?

Object-oriented programming (OOP) is a programming model that organizes software design around data, rather than functions and logic. An object is a data field that has distinct attributes and behavior.

It focuses on the objects that developers want to manipulate rather than the logic required to manipulate them. This programming approach is ideal for large, complex programs that are constantly updated or maintained.

The structure of an object-oriented program also lends itself to collaborative development, where projects are divided into groups. Other advantages of OOP include code reusability, scalability, and efficiency.

An object can be anything from a physical thing, such as a person who is identified by attributes like name and address, to a simple computer program.

Structure of OOPs

Structure of OOPs

  • Classes are custom data types that serve as the foundation for individual objects, attributes, and methods.
  • Objects are instances of a class that are created with specific data. Objects can be real-world objects or abstract entities. When a class is first defined, the description is the only object defined.
  • Methods are functions defined within a class that describe an object’s behaviors. Every method in a class definition begins with a reference to an instance object. In addition, the subroutines contained within an object are referred to as instance methods. Methods are used by programmers to ensure reusability or to keep functionality contained within a single object at a time.
  • Attributes are defined in the class template and represent an object’s state. Data will be stored in the attributes field of objects.

Principles of OOPs

  • Abstraction - Objects only reveal internal mechanisms that are necessary for the use of other objects, while hiding any unnecessary implementation code. The functionality of the derived class can be extended. This concept can make it easier for developers to make additional changes or additions over time.
  • Encapsulation - According to this principle, all important information is contained within an object and only a subset of it is exposed. Each object’s implementation and state are kept private within a defined class. Other objects do not have access to or authority over this class. They can only call a set of public functions or methods. This data hiding feature improves program security and prevents unintended data corruption.
  • Inheritance - Code from other classes can be reused by classes. Relationships and subclasses can be assigned to objects, allowing developers to reuse common logic while still maintaining a distinct hierarchy. This OOP property forces a more thorough data analysis, reduces development time, and ensures greater accuracy.
  • Polymorphism - Objects are intended to share behaviors and can take on multiple forms. The program will determine which meaning or usage is required for each execution of that object from a parent class, which reduces the need for duplicate code. The parent class’s functionality is then extended by creating a child class. Polymorphism enables various types of objects to pass through the same interface.

Thank you for reading

Let’s connect on Twitter

Thanks for reading!