In simple words, abstraction captures only those details about an object that are relevant to the current perspective.
In computer science, abstraction is the process by which data and programs are defined with a representation similar in form to its meaning (semantics), while hiding away the implementation details. –WikiPedia
Table of Contents What is abstraction Types of abstraction How to use abstraction in java
What is abstraction
In object-oriented programming theory, abstraction involves the facility to define objects that represent abstract “actors” that can perform work, report on and change their state, and “communicate” with other objects in the system.
Abstraction in any programming language works in many ways. It can be seen from creating subroutines to defining interfaces for making low level language calls.
Some abstractions try to limit the breadth of concepts a programmer needs, by completely hiding the abstractions they in turn are built on, e.g. design patterns.
Types of abstraction
Typically abstraction can be seen in two ways:
Data abstraction is the way to create complex data types and exposing only meaningful operations to interact with data type, where as hiding all the implementation details from outside works.
Benefit of this approach involves capability of improving the implementation over time e.g. solving performance issues is any. The idea is that such changes are not supposed to have any impact on client code, since they involve no difference in the abstract behavior.
A software is essentially a collection of numerous statements written in any programming language. Most of the times, statement are similar and repeated over places multiple times.
Control abstraction is the process of identifying all such statements and expose them as a unit of work. We normally use this feature when we create a function to perform any work.
How to use abstraction in java
As abstraction is one of core principles of Object oriented programming practices, and Java following all OOPs principles, abstraction is one of major building block of java language.
Data abstraction spans from creating simple data objects to complex collection implementations such as HashMap or
HashSet. Similarly, control abstraction can be seen from defining simple function calls to complete open source frameworks. control abstraction is main force behind structured programming.
Most discussed topics regarding abstraction in java includes abstract classes and interfaces.
If you want to read more about abstract classes and interfaces in java, follow my next post Exploring interfaces and abstract classes in java.
Happy Learning !!