Difference Between Abstraction and Data Hiding


In object oriented programming (OOP), abstraction and data hiding are two important concepts. Abstraction is a process of extracting important information without involving the complete detail of the system. On the other hand, data hiding is a process of wrapping the data in a single unit, i.e., to achieve data encapsulation.

Read this article to learn more about abstraction and data hiding and how these two concepts are different from each other.

What is Abstraction?

Abstraction, or data abstraction, is one of the object-oriented methodologies. Abstraction is defined as the process of hiding the internal implementation and keeping the complicated procedures hidden from the user. Thus, abstraction only displays the required services or parts of the system. This is usually achieved using the 'abstract' class concept, and by implementing interfaces.

In abstraction, only the important details of the system are highlighted and the rest of the intricate details are not shown to the user.

Types of Abstraction

There are three types of abstraction, namely,

  • 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.

Abstraction helps in securing the software. It does not affect endusers, since the developers can perform changes internally. Abstraction ensures that the application is flexible and user-friendly.

What is Data Hiding?

In OOP, data hiding refers to the task of hiding the internal data from outsiders. With the help of data hiding, the internal data would not be accessible by irrelevant people. Data hiding can be achieved using access specifiers, such as 'private', and 'protected'. It acts like a security layer as it ensures that users cannot access internal data without authentication.

In data hiding, getters and setters can be used to access the data or to modify it. "getters" help in accessing the private data, while "setters" help in changing the settings of data, i.e., modifying the private data.

Difference between Abstraction and Data Hiding

The following table highlights all the important differences between abstraction and data hiding −

S.No.

Abstraction

Data Hiding

1.

The process of hiding the implantation details and showing only the functionality of program is referred to as abstraction.

The process of hiding important and sensitive data from any unintended access is known as data hiding.

2.

Abstraction helps in extracting relevant information from a larger set of information.

Data hiding helps to increase safety by preventing outside attacks.

3.

Abstraction focuses on reducing the complexity of code.

The purpose of data hiding is to achieve data encapsulation.

4.

Abstraction solves the design level problems.

Data hiding solves the implementation level problems.

5.

There are three types of data abstractions namely, procedural abstraction, data abstraction, and control abstraction.

Data hiding is not divided into subtypes.

Conclusion

The most significant difference between the two is that data abstraction is used to hide the complexity of the system, while data hiding is used to achieve encapsulation of data.

Updated on: 20-Feb-2023

7K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements