What is abstraction? [closed]

Abstraction is the technique of hiding implementation. At it's core there's not much more to that answer. The bulk of meaning to abstraction come from how and why it is used.

It is used for the following scenarios

  • Reduce complexity. (Create a simple interface)
  • Allow for implementation to be modified without impacting its users.
  • Create a common interface to support polymorphism (treating all implementations of the abstracted layer the same.
  • Force users to extend the implementation rather than modify.
  • Support cross platform by changing the implementation per platform.

Quite simply, abstraction is the art of limiting your dependencies. The less you depend on, the more abstract you are. For example, if you write a DirectX renderer, then you're abstracted from what graphics card vendor and model you're running on. If you write another layer, you can be insulated from what OS you're running on.


Abstraction is hiding details of specific implementations and share common details among implementations. Example is java.util.List, java.util.ArrayList and java.util.Map. List is the parent (the abstraction), ArrayList and Map are specific implementation.

You want to do this whenever you have shared code between different classes, so that you don't repeat your code which is bad.

Abstraction is very useful in code reuse, dynamic behavior and standardization. For example, there is a method that you are using and it accepts a List, so to use this method, you can send any object that has list as its parent. Now inside this method, there could be different implementations depending on what is the type of the passed object, so you can achieve a dynamic behavior at run-time. This is very useful technique when you design a framework.