What’s data hiding?

Print anything with Printful



Data hiding in object-oriented programming hides information from objects, providing advantages such as increased security and isolation of objects. However, it may require more code to access hidden data, and if made public, can damage the object and be manipulated by hackers.

Data hiding is a method used in object-oriented programming to hide information within computer code. Objects within a code are unaware of information considered hidden. It has several advantages for programmers, because objects are unable to connect to irrelevant data and hackers are less likely to access the data. At the same time, hiding data can make it more difficult for a programmer, who may need to use more code to create effects in the hidden data than would be necessary if the data were public.

Object-oriented programming is a type of programming in which parts of the code are divided into objects. Each of these objects is programmed in capsules, so each object has its own encoding that applies only to that object. Without specifying the data as hidden, all data is open to objects.

Data hiding takes some parts of your code and hides those parts from objects. Objects cannot access hidden data directly. If an object accesses hidden data, it will return an error. This is because the object cannot see the data, so any function or data labeled as hidden will appear invisible to the object. Most of the time, hidden data is internal components that are not needed by the user and can be dangerous if the data is opened to the user.

The benefit for programmers is that there is no way for a programmer to accidentally link to bad data. Data hiding ensures that if a programmer makes this link, the program will simply return an error so that the programmer can quickly fix the error. This also ensures that all objects are truly isolated units, which is the main concept of object-oriented coding. Volatile data is usually hidden because, if made public, it could damage the object and destroy the entire program.

Another benefit of data hiding is increased security against hackers. If all internal data is public, a hacker can easily infiltrate internal data and make changes to manipulate the program in a malicious way. By hiding the data, it is much more difficult to crack the code, because the data will appear invisible to objects and to the hacker.
The downside of data hiding is that it can sometimes force programmers to use additional code. If a programmer is able to plug into hidden data, he can make objects work faster or reduce a large amount of code. Most programmers don’t keep all the information public, however, due to all the problems associated with this type of coding.




Protect your devices with Threat Protection by NordVPN


Skip to content