Learn the basics of abstraction in object-oriented programming with example code and practice challenges. By Lee Nathan.
Along with inheritance, abstraction is an important concept in object-oriented programming. The theory is that every object should deliver simple and predictable results. Objects should also only share what needs to be shared.
The article dives into:
- Abstraction keeps code and data hidden when appropriate
- Abstraction is closely tied to encapsulation
- Why classes should sometimes be abstract
- What is abstract and what is concrete?
- Abstraction practice
- But what is the point of a class you can’t instantiate?
At first, abstract classes may seem unnecessary. After all, you can’t actually use them to make an object. And it’s not like they pass down their functions. Functions have to be rewritten in every child class. You will get code examples and link to the sandbox to practice abstraction with JavaScript. Good read!
[Read More]