Encapsulation
Encapsulation is one of the most important pillars of OOP. It refers to the concept of declaring state variables that cannot be accessed directly by clients and can only be accessed and modified using functions. This helps in restricting access to variables but, at the same time, allows enough access to the class for taking action on it.
Solidity provides multiple visibility modifiers, such as external
, public
, internal
, and private
, which affect the visibility of state variables within the contract in which they are defined, inheriting child contracts or outside contracts.
After covering inheritance and encapsulation, the next important object-oriented concept is polymorphism, which is the next topic of discussion.