Encapsulation

Encapsulation is approach for restricting direct access to some of the data structure elements (fields, properties, methods, etc)

Abstraction and encapsulation are complementary concepts: Abstraction focuses on the observable behavior of an object, whereas encapsulation focuses on the implementation that gives rise to this behavior.

Encapsulation is most often achieved through information hiding (not just data hiding), which is the process of hiding all the secrets of an object that do not contribute to its essential characteristics; typically, the structure of an object is hidden, as well as the implementation of its methods.

Encapsulation provides explicit barriers among different abstractions and thus leads to a clear separation of concerns. Objects at one level of abstraction are shielded from implementation details at lower levels of abstraction.

Last updated