Object Oriented Programming

Object Oriented Programming (OOP) is a programming paradigm based on the concept of classes and objects. Several languages have object orientation such as C#, Java, C++, JavaScript, PHP, TypeScript etc.

Object Oriented Programming is based on 4 pillars which are Abstraction, Encapsulation, Inheritance and Polymorphism.

 

Abstraction

The abstraction is divided into 3 parts the identity of the object, its characteristics and its actions. The identity must be unique, ensuring that the object is not duplicated in the system. Its characteristics are like those of a real object, I will use a dog as an example, the dog has Color, Name, Race, Age etc. Following the example of the dog, we have the actions that can be, for example, Run, Bark, etc.

 

Encapsulation

This concept says that in a class objects should only be revealed to other classes if relevant, which facilitates the maintenance and implementation of new features.

 

Inheritance

Inheritance comes from the principle of reducing code repetition, with the functionality of inheriting attributes and methods from other classes, such as you inherit characteristics from your parents.

 

Polymorphism

Polymorphism goes hand in hand with inheritance, and consists in being able to modify methods and attributes of its parent, such as, for example, a generic Car class that has the Connect method, which can be different in a ManualCar and an ElectricCar, giving us the option to modify the way the Car starts.

 


← Back to home