What is it?

OOP, which stands for object-oriented programming, is a programming paradigm designed around data structures instead of functions and logic. The object are data fields which can have its own properties, attributes and methods, characterizing unique behaviors for each object.

Some languages like C-Sharp and Java use the object-oriented paradigm as the only way to write code, while other languages like Python, while still use objects as the basis of the entire language, also supports procedural programming .


The principles of OOP

OOP has three basic principles: encapsulation, inheritance, and polymorphism. Some authors refer to abstraction as the fourth principle, which refers to the abstracting the heavy logic into base objects.

  • Encapsulation

This is the mechanism of restricting access to data and parts of the code. Each object should control its own data, methods, and properties. Think about what really needs to be exposed and what should be kept private.

  • Inheritance

This is the mechanism in which one object reuses the functionality, properties, and methods of another object. This brings reusability to the table, so instead of creating another very similar object, create a base, and from that inherit all the children objects.

  • Polymorphism

Polymorphism means “the condition of occurring in several different forms”. Types in the same inheritance chain should be able to perform different tasks, while children objects share functionality, but are also able to define its own implementations.