Learn something new every day
More Info... by email
Data hiding is a method used in object-oriented programming to hide information within computer code. Objects within a code are not privy to information considered hidden. It presents several advantages for programmers, because objects are unable to connect to irrelevant data and hackers are less likely to be able to access data. At the same time, hiding data can make it harder for a programmer, who may need to use more code to create effects in 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 split into objects. Each of these objects is programmed in capsules, so each object has its own coding that applies only to that object. Without specifying data as hidden, all the data is open to the objects.
Data hiding takes certain parts of code and hides those parts from the objects. The objects cannot directly access any data that is hidden. If an object does access hidden data, it will return an error. This is because the object cannot see the data, so any functions or data that are labeled as hidden will look invisible to the object. Most of the time, the data being hidden are the internal components that are not needed by the user and can prove dangerous if the data are laid open for the user.
The advantage for programmers is that there is no way for a programmer to accidentally link to incorrect data. Data hiding ensures that, if a programmer does make this link, the program will simply return an error so the programmer can quickly correct the mistake. This also ensures that all of the objects are truly isolated units, which is the main concept of object-oriented coding. Volatile data are typically hidden because, if such data were made public, it could damage the object and destroy the entire program.
Another advantage of data hiding is heightened security against hackers. If all internal data are public, a hacker can easily squeeze into the internal data and make any changes to manipulate the program maliciously. By hiding the data, it's much harder to crack the code, because the data will appear invisible to the objects and the hacker.
The disadvantage of data hiding is that it can sometimes force programmers to use extra coding. If a programmer is able to link to hidden data, it can make objects work faster or cut down on a large amount of code. Most programmers do not keep all information public, though, because of all the problems associated with this type of coding.
This information was very helpful in writing a paper for my current class. It helped me understand data hiding because it was explained in such a simple way.
One of our editors will review your suggestion and make changes if warranted. Note that depending on the number of suggestions we receive, this can take anywhere from a few hours to a few days. Thank you for helping to improve wiseGEEK!