In this post, we will understand the difference between data abstraction and data hiding.
It is one of the object-oriented methodologies.
It is defined as the process of hiding the internal implementation and keeping the complicated procedures hidden from the user.
Only the required services or parts are displayed.
This is usually achieved using ‘abstract’ class concept, and by implementing interfaces.
Only the important details are highlighted.
The rest of the intricate details are not shown to the user.
There are three types of abstraction
Procedural abstraction − Procedures are written as methods/functions one followed by the other. It is done in sequence in order to obtain abstraction.
Data Abstraction − Abstraction is achieved using data set that is used to describe the object of the class.
Control Abstraction − Here, it is achieved by using objects by ensuring that the details of the object are hidden from user.
It helps secure the software.
It doesn’t affect end users, since the developers can perform changes internally.
It ensures that the application is flexible, and user-friendly.
It can be implemented by creating a class that only represents important attributes, without including background detail.
Data hiding refers to the task of hiding the internal data from outsiders.
The internal data won’t be accessible by irrelevant people.
This can be achieved using access specifiers, such as ‘private’, and ‘protected’.
This acts as a security layer.
This ensures that users can’t access internal data without authentication.
Getters and setters can be used to access the data or to modify it.
Getters help in getting, i.e accessing the private data.
Setters help in changing the settings of data, i.e modifying the private data.