This is the process that data goes through when it’s transmitted through a computer by way of protocols. There are different layers of protocols and each of them alters the data a little bit, changing it enough that it will pass the next layer and can then be sent via the network. On the other machine, this process is reverse, and the data is put back into its original ‘shape’ so that applications and users can interact with it.
Technipages Explains Encapsulation
Encapsulation works a little bit like paint does – as data passes through layers of protocols, it changes, little by little. Once it has passed through all of them, it can be transmitted via a network connection like the Internet. Once the data, layered as it is, reaches the other machine, the encapsulation process is reversed, and layer by layer, the data is put back together to the way it was. When that’s done, the data can be used, just like on the original machine.
This process is an important aspect of object-oriented programming – part of that is a ‘rule’ that some things and aspects of data should not be available to other objects. The data can still be moved through communication channels (in this case, usually a network), but it can’t be directly altered or even accessed while in motion. Once reversed, the data is back in its original state.
Common Uses of Encapsulation
- Encapsulation is an essential aspect of OoP.
- Data transfer puts data through an encapsulation process.
- Encapsulation restricts direct access to an objects components and properties.
Common Misuses of Encapsulation
- Encapsulation protects data against viruses.