Course Object Oriented Programming

Pillar 2: Encapsulation

Course's Page 6 min Text by
User Image
Abacate

Hello, in this class we will see the 2nd pillar of Object Oriented Programming: Encapsulation.

What is encapsulation?

It's a pillar that adds security and intuitiveness to our program.

Encapsulation means: put in a capsule.

In programming, it means hiding parts of the implementation so they can only be accessed using specific methods.

Analogy

Imagine a Xbox controller:

The controller has several buttons (methods), a case(capsule) and several internal components (attributes).

When executing each of the buttons, the control performs several actions using its internal components.

Thus, we say that the internal components (attributes) of the controller are encapsulated (protected).