Encapsulation

up:: OOP Principles

Tldr

To keep some methods private, ie. inaccessible, from outside the class.

For example, in the login method, we need to use the username and password. Anywhere outside we don’t want to be able to manipulate that data. This helps avoiding bugs.

Some methods can be exposed to the outside through an API.