abstraction vs data hiding
Abstraction and Data hiding are the crucial concepts of the object-oriented programming. Abstraction is a method of expressing the important properties without involving the background details. On the other hand, Data hiding insulates the data from the straight access by the program. Although, both the concepts sound similar in the sense but are different. The abstraction provides a way to create user-defined data types for designing real-world objects having same properties. As against data hiding protects the data and function from the unauthorized access.

Content: Abstraction Vs Data Hiding

  • Comparison Chart
  • Definition
  • Key Differences
  • Conclusion

Comparison Chart

BASIS FOR COMPARISONABSTRACTIONDATA HIDING
BasicExtracts only relevant information and ignore inessential details.Hides the data from the parts of the program.
PurposeTo hide the complexity.To achieve encapsulation.
ClassClass uses the abstraction to derive a new user-defined datatype.Data hiding is used in a class to make its data private.
Focusses onObservable behavior of the data.Restricting or allowing the use of data within a capsule.

Definition of Abstraction

Abstraction is primarily used to hide the complexity. It indicates the necessary characteristics of an object that differentiates it from all other types of objects. An abstraction concentrates on the external aspect of an object. For an object, abstraction provides the separation of the crucial behaviour from its implementation. It specifies a conceptual boundary relative to the outlook of the viewer. A proper abstraction emphasizes on the details that are important for the reader or user and suppresses features that are, irrelevant and deviant.
User-defined data types are created by defining abstract attributes and functions within a class for designing real-world objects, having alike properties. These attributes are known as data members because they contain the information. Similarly, the functions that operate on these data are known as member functions. Data abstraction is implemented as a class which represents the essential properties without including the background explanations.

Types of Abstraction:

  • Procedural abstraction – It includes series of the instructions having the specified functions.
  • Data abstraction – It is set of data that specifies and describes a data object.
  • Control abstraction – It is program control mechanism where interior details are not specified.

Definition of  Data hiding

Data hiding implies the hiding of the data from the components of the program that don’t need to be retrieved. The isolation of the data from the direct access by the program is called data hiding or information hiding. For implementing data hiding, encapsulation is used where data and function of a class is protected from unauthorized access. In contrast, when the data and function is encased into a single unit is known as encapsulation. Hence, the data hiding assists in achieving the encapsulation. The functional details of an object can be handled through access specifiers.
Using the data hiding concepts, the data and function in a class is made private so that it could not be accessed falsely by the functions outside the class and protected from accidental alteration.

Key Differences Between Abstraction and Data hiding

  1. Abstraction shows the relevant information and rejects the non-essential details. On the other hand, data hiding is used to hide the data from the parts of the program.
  2. The prior purpose of abstraction is to hide the complex implementation detail of the program or software. On the contrary, data hiding is implemented to attain encapsulation.
  3. Abstraction is used in class to create a new user-defined datatype. As against, in classes data hiding is used to make the data private.
  4. The abstraction concentrates on the observable behaviour of the data whereas data hiding restricts or allow the use of data within a capsule.

Conclusion

Both abstraction and data hiding intended to just show the required information and hiding the inessentials details but for the distinct purpose. Abstraction emphasizes in hiding the implementation complexity while in data hiding the prominence is given to the protection of data against the unauthorised access.