Reviewing Objected Orientated Programming Principles: Quick Overview of The Four Pillars
Object Orientated Programming (OOP) is the approach to managing the flow of data within objects. Objects are data that we want to model from the world like for example a dog, phone, driver’s license, etc. The four main pillars for OOP are abstraction, encapsulation, inheritance, and polymorphism.
Abstraction is to only show the details to the user of the object. Only exposing the necessary details needed by whomever is using the object. A great thing from abstraction is that it decouples the user from the underlying implementation. We only care about calling the method and not the underlying implementation.
Encapsulation represents data and functions within a module or class. Objects are accessible by instances or objects of that class. The state of the object can be managed via the functions in the enclosed information. Use of private method is very useful.
Inheritance is to pass down data, function and methods from the base class or parent class over to a sub class or child class. This is helpful because it minimizes code redundancy and provides code reusability. It can create a hierarchical inheritance tree.
Polymorphism is to alter objects’ methods and functions that they inherited from other objects. Can call the child object’s method if the method was overwritten.