Abstraction is one of the fundamental Object Oriented Programming concepts. It is a mechanism to show only essential data and hide the internal implementation of software, this is known as method hiding.
Why need Abstraction?
Object Oriented Programming helps to manage the complexity of understanding things with the help of abstraction. A client doesn't need to know how the car engine works when it starts/stops, all they care is ease of use. So the actual Engineer hides all the internal engine mechanisms and provides the essential info(a simple key mechanism to start/stop the car). Similarly in the programming world a software developer hides all the implementation of a car engine and provides only the essential info to start the car.
With the help of inheritance, this approach helps the engineers to hide the internal details and show only the essential information. In the future, if taxCalucation() process needs to be updated due to tax percentage increase or money inflation then the engineer works on the hidden internal details and the client still receives the proper essential information(tax to be paid result) without knowing the internal details.
How to achieve abstraction?
- Create a abstract class or interface
- Create a abstract method (declare a method)
- Create a class that inherits abstract class or interface
- Provide the implementation to abstract method