DEV Community

Cover image for OOP - The Four Pillars
Arthur
Arthur

Posted on

OOP - The Four Pillars

I was once asked what this was and to my surprise was not able to answer in my own words. So here's another blog to document my learning!

Object-Oriented Programming (OOP) sounds like a can of worms but not something that sounds too impossible to understand.

Here is what I learnt and understand from the four pillars of OOP:

  1. Abstraction - automate the implementation of code across the code base by abstracting away the logic of code.

  2. Encapsulation - hiding data from a specific place so that other places of the code can't use it. This prevents 'spaghetti' code if everything was made 'global'.

  3. Inheritance - allowing an object to receive the same properties or likeness from it's parent object E.g. sharing the same property.

  4. Polymorphism - where types in the inheritance chain can do different things

That's it!

Would you agree? Comment below for your thoughts :)

Top comments (0)