Four Pillars of Object Oriented Programming

We have to admit, we know and use the “4 Pillars” Of Object Oriented Programming but let’s be honest here there are some of us who tends to forget what are the “4 pillars” of OOP or what is their somehow technical explanation.

if you are like me, who tends to use them a lot but always can’t find the words to explain it to friend or a colleague then this is something worth your time recalling.

So What are the 4 pillars of OOP ? Let’s start!

1.Abstraction
Abstraction is a process of exposing essential feature of an entity while hiding other irrelevant detail. Why would you want to use abstraction?

abstraction reduces code complexity and at the same time it makes your aesthetically pleasant.

2.Encapsulation
We have to take in consideration that Encapsulation is somehow related to Data Hiding.
Encapsulation is when you hide your modules internal data and all other implementation details/mechanism from other modules. it is also a way of restricting access to certain properties or component.

Remember, Encapsulation is not data hiding, but Encapsulation leads to data hiding

3.Inheritance
Like the word Inheritance literally means it is a practice of passing on property, titles, debts, rights and obligations upon the death of an individual. in OOP this is somehow true(Except the death of an individual) , where The base class(the existing class sometimes called as the Parent class) has properties and methods that will be inherited by the sub class(sometimes called a subtype or child class) and it can have additional properties or methods.

The ability of creating a new class from an existing class. 

4. Polymorphism
Just like in biology, Polymorphism refers to the ability to take into different forms or stages. A subclass can define its own unique behavior and still share the same functionalities or behavior of its parent/base class.Yes, you got it right, 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.

Polymorphism is the ability of an object to change behavior on runtime

There are more in-depth details about the 4 pillars of OOP in the web. I am just here to remind you what are they. Hopefully this is enough for you to recall everything you have forgotten about the pillars of OOP.

Leave a comment