4 PILLARS OF OOP

Ehtisham Raza
An Idea (by Ingenious Piece)
3 min readOct 23, 2020
Photo by Jefferson Santos on Unsplash

What is Object Oriented Programming?

Object Oriented programming (OOP) is a programming paradigm that relies on the concept of classes and objects. It is used to structure a software program into simple, reusable pieces of code blueprints (usually called classes) which are used to create individual instances of objects. Because OOP is a programming paradigm, there are many object-oriented programming languages including: C++, Java, and Python.

A programmer designs a software program by organizing related pieces of information and behaviors together into a template called a class. Then individual objects are created from the class template. The entire software program runs by having multiple objects interact with objects to create the larger program.

4 Pillars of OOP

Photo made by Canva

The four pillars for OOP are Abstraction, Encapsulation, Inheritance, Polymorphism.

1.Abstraction

Abstraction is the process of showing only essential/necessary features of an entity/object to the outside world and hide the other irrelevant information. For example to open your TV we only have a power button, It is not required to understand how infra-red waves are getting generated in TV remote control.

Photo made by Canva

2.Encapsulation

Encapsulation means wrapping up data and member function (Method) together into a single unit i.e. class. Encapsulation automatically achieve the concept of data hiding providing security to data by making the variable as private and expose the property to access the private data which would be public.

Photo made by Canva

3.Inheritance

The ability of creating a new class from an existing class. Inheritance is when an object acquires the property of another object. Inheritance allows a class (subclass) to acquire the properties and behavior of another class (super-class). It helps to reuse, customize and enhance the existing code. So it helps to write a code accurately and reduce the development time.

Photo made by Canva

4.Polymorphism

Polymorphism is derived from 2 Greek words: poly and morphs. The word “poly” means many and “morphs” means forms. So polymorphism means “many forms”. A subclass can define its own unique behavior and still share the same functionalities or behavior of its parent/base class. A subclass can have their own behavior and share some of its behavior from its parent class not the other way around. A parent class cannot have the behavior of its subclass.

Photo made by Canva

If you find this article insightful leave your comments I’ll appreciate it.

Thanks for Reading this Article…………………..

--

--