Object Oriented Programming/Encapsulation

Encapsulation

In-the oriented approach, classes,and therefore also objects of that class,are similar to black boxes with a clearly defined interface. This interface is the only mechanism that other objects can use to communicate with the object

We say that inside a class, behind the interface, the data and implementation of the operations are encapsulated or enclosed in a capsule.

This makes the internal workings of a class invisible to all other classes. This is a good technique, since there is no need for other classes to know the internal structure of this class,in other words, how it represents its data and how it performs its operations. We call this encapsulation information hiding.

See also

edit