Understanding OOP principles
OOP is a way of bundling properties and behavior into a single entity, which we call objects. To make this bundling more efficient and modular, there are several principles available in Python, outlined as follows:
- Encapsulation of data
- Inheritance
- Polymorphism
- Abstraction
In the next subsections, we will study each of these principles in detail.
Encapsulation of data
Encapsulation is a fundamental concept in OOP and is also sometimes referred to as abstraction. But in reality, the encapsulation is more than the abstraction. In OOP, bundling of data and the actions associated with the data into a single unit is known as encapsulation. Encapsulation is actually more than just bundling data and the associated actions. We can enumerate three main objectives of encapsulation here, as follows:
- Encompass data and associated actions in a single unit.
- Hide the internal structure and implementation details of the object...