The Four Pillars of Object-Oriented Programming

Osgood Gunawan
2 min readNov 30, 2020

As we all know, the most popular paradigm of today technology is Object Oriented Programming(OOP). Today in top companies’ technical interviews, you need to know about solving algorithms and data structure problems and be able to explain the basic principles of Object-Oriented Programming as well as System design principles (this will be another blog topic). If you are programming with this particular paradigm, you will often hear interviewers asking the four basic principles of Object-Oriented Programming.

What are the four pillars of OOP?

Encapsulation

  • Encapsulation is the mechanism of hiding data implementation by restraining access to public methods. Instance variables are kept private, and accessor methods are made public to achieve this. We are encapsulating the properties within the Object by setting properties as private. Let the users control the getter or setter method for whatever they want them to set and get with.

Inheritance

  • This principle is the most used in OOP. It is the ability to create a new class from an existing class. It helps to reuse, customize, and enhance the existing code. It helps to write a code accurately and reduce the development time.
  • Allows a class (subclass) to acquire the properties and behavior of another class(superclass).
  • When an object acquires the property of another object.

Polymorphism

  • This is probably the most complicated one. It means one name in many forms and closely related to inheritance.
  • A subclass can have its 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.
  • You can call methods on a class if what is calling is a pointer of a parent object.

Abstraction

  • is an idea/concept that is not associated with any particular instance. The process of showing only essential/necessary features of an entity/object to the outside world and hide the other irrelevant information. For instance: 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.
  • We only care about calling the method, and we don’t care about the underlying implementation of that method.

So there you have it! That is the four pillars of OOP; you can always check the reference for a more detailed explanation.

Reference

https://blog.alexdevero.com/principles-of-object-oriented-programming/

https://www.youtube.com/watch?v=1ONhXmQuWP8

--

--

Osgood Gunawan

UX designer | Software Engineer | Dancer | ETL Developer | Data Migration. More about me : https://www.osgood1024.com/