I do not understand abstraction in JS OPP

Hey I am trying to understand this pillar of OOP and I cannot grasp it
can someone explain it to me and give me some example and what does it mean by reduce the impact of change

video link

Abstraction is about simplification. For example, the Set object in JavaScript, which is an abstraction that gives you a simple way to work with a set of unique data. You don’t need to know about all the complexity that went into making the Set object, you just need to know relatively simple things, like Set.add adds items to the set, Set.delete removes items, and so on. “Reduce the impact of change” means that the folks who made the Set object could decide to change its inner workings, for example maybe they found a way to improve its performance. As long as they don’t change the abstraction i.e. as long as there’s still a Set.add and Set.delete, then you can continue to use the Set just like you did before; you haven’t been negatively impacted by the changes.

1 Like

Hey sorry for replying lately
but How can I use abstraction in real life projects

almost everything in programming is an abstraction of some kind or another so I would encourage you to not worry about this - just start programming.

Specifically in the world of OOP they make a big deal about abstraction (as if it had never existed until object oriented program invented it). But its a simple idea - a class exposes WHAT it does but not HOW it does it. In OOP you do this by creating classes with public methods. The public methods are the abstraction.

For example - if you create a database access class that exposes a two methods, one called ConnectToDatabase() and one called ExecuteQuery(), then you have abstracted the details of how to connect to a database. All that the users of your class know is that they can call these methods - but you are free to “hide” the details of how they work from view. So the abstract view of this is that you can connect to a database and execute a query.

But as I said, pretty much this is just writing code. If you are writing code in Java, you are using abstractions all the time so don’t worry about it too much just keep studying and practicing.

1 Like