Member-only story

Abstraction in OOP

Bernardo Teixeira
2 min readMar 25, 2020

--

In object-oriented programming, abstraction is one of three central principles (along with encapsulation and inheritance). Through the process of abstraction, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency. — Google

Photo by Florian Olivo on Unsplash

But what really means abstraction?

Imagine this, you have a washing machine. You don’t really know how it works, you just know the input and the output.

The process, if the machine first gets water then soap or soap then water, you don’t know.

Abstraction is exactly that you just know the input and the output. But you don’t know the process.

Abstraction in programming

Similar to the washing machine, you just need to know which methods of the object are available to call and which input parameters are needed to trigger a specific operation. But you don’t need to understand/know how this method is implemented and which kinds of actions it has to perform to create the result.

Advantages of using Abstraction

Enables implement more complex logic on top of the provided abstraction without understanding or even thinking about all the hidden complexity. One big use case is Dependency Injection.

--

--

Bernardo Teixeira
Bernardo Teixeira

Written by Bernardo Teixeira

Software Engineer.. Red Panda Lover

No responses yet