DEV Community

Cover image for Four Pillars of OOP

Posted on

Four Pillars of OOP

A brief overview of the four pills of Object-Oriented Programming (OOP)


What are the four pillars of OOP?


The four pillars of OOP are encapsulation, abstraction, inheritance, and polymorphism.


  • Encapsulation is the idea of containing the attributes and behaviors of a class within itself. The state is secured and is private to the class. Only the object itself can update the state, and other objects only have access to the object's state through public methods.


  • Abstraction is the way in which we select and present the pertinent information for an object. All the mechanisms under the hood need not be presented, but the high-level data will be.


  • Inheritance is a way in which an object acquires some/all of the properties of another object. It is a great way to reuse code and build on top of previously created objects.


  • Polymorphism is distinct from inheritance because the object acquires some/all of the properties of another object, but the object will maintain its own unique methods and functions.


The four pillars are fundamental to OOP. Commit them to memory!

& Remember... Happy coding, friends! =)

Top comments (1)

eljayadobe profile image

In contrast, for FP, the pillars (as I see them) are:

  • immutability
  • recursion
  • pattern matching
  • higher-order functions
  • code as data
  • separation of behavior from data
  • referential transparency