Encapsulation (Đóng gói)

Bên trong mỗi đối tượng (trong lập trình hướng đối tượng) có chứa dữ liệu thể hiện tình trạng hay thuộc tính của nó. Mỗi đối tượng được trang bị những hành vi ( behavior) hay phương thức ( [method]) để thực hiện một số nhiệm vụ nhất định, nhằm thông báo hay làm thay đổi thuộc tính của chính nó. Đối tượng là sự kết hợp dữ liệu và thao tác trên dữ liệu đó thành một thể thống nhất. Sự kết hợp như vậy gọi là sự đóng gói.

By English

In programming languages, encapsulation is used to refer to one of two related but distinct notions, and sometimes to the combination thereof:

A language mechanism for restricting access to some of the object's components.

A language construct that facilitates the bundling of data with the methods (or other functions) operating on that data.

Some programming language researchers and academics use the first meaning alone or in combination with the second as a distinguishing feature of object oriented programming, while other programming languages which provide lexical closures view encapsulation as a feature of the language orthogonal to object orientation.

The second definition is motivated by the fact that in many OOP languages hiding of components is not automatic or can be overridden; thus, information hiding is defined as a separate notion by those who prefer the second definition.

Like Doanh nhân số