Object Oriented Programming — Abstraction
- Abstraction :
Let’s Understand Abstraction. Abstraction is like hiding the implementation details for security.
Abstractions is achievened through abstract classes or interfaces.
Example : toString() method here we call method to convert into string without knowing and manipulating toString() implementation logic.
Example :
Consider that your are working on any live project related to Logistics (Delivering the shipments)
now,
Let’s say your product involves interacting with multiple transport companies for their invoices and your are getting invoices through file and you are writing file processing jobs for this
Now here,
You can implement a abstract class that involves logic of —
1. reading headers
2. opening the files
for this you can create a abstract class and logic to read and process file you can write them into different subclasses as per need. You are hiding unnecessary details here and reusing this code multiple times.
Get Yashraj Santosh Chavan’s stories in your inbox
Join Medium for free to get updates from this writer.
Basically this class becomes common blueprint for all the classes that details with multiple invoices.
Difference between abstraction and Interface
Major : Interfaces don’t have logic only contract and abstraction forces child classes to implement their part






