Data Abstraction

The concept of representing important details and hiding away the implementation details is called data abstraction. This programming technique separates the interface and implementation. Data abstraction is also an OOP feature.

Abstraction tries to minimize details so that the programmer can focus on a few concepts at a time. Abstraction is the basis for software development.

Data abstraction definition
Abstraction refers to the act of focusing on important details or characteristics and filtering out the unwanted details or explanations.

Classes use the concept of abstraction.

C++ example of abstraction

#include <iostream>
using namespace std;

int main()
{
cout<<"Data Abstraction Example"<<endl;
return 0;
}

In c++, cout displays the specified text on the console but we don’t need to understand how cout displays it. It’s implementation code is written somewhere in the header file iostream. We only have to care about the interface and not the underlying implementation and thus abstraction makes our programming task easy.

Advantages of Abstraction

  1. The programmer does not have to write the low-level code.
  2. The programmer does not have to specify all the register/binary-level steps or care about the hardware or instruction set details.
  3. Code duplication is avoided and thus programmer does not have to repeat fairly common tasks every time a similar operation is to be performed.
  4. It allows internal implementation details to be changed without affecting the users of the abstraction.