Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is abstraction? [closed]

Tags:

abstraction

I see abstraction in processes. I see abstraction in data.

I see that abstraction is losing the unimportant details.

I see that abstraction is giving a group of elements a name and treating them as one unit. (But I don't know why that is considered abstraction. So, please I need clarification on this particular point)

I know there are also levels of abstraction, and although the name implies something, I don't have a practical example, and I can't think of a specific one I'm confused about the definition of abstraction.

Can somebody write a comprehensive article? Scratch that. Can somebody give a comprehensive answer?

EDIT:- Thank you for your answers. However, I was looking for a generalized answer. For example, I'm reading an article in which procedures are considered abstractions. However, here the answers are about abstract classes in C# and Java, (until now.) Thank you again.

like image 556
wajed Avatar asked Aug 11 '11 15:08

wajed


People also ask

What is the concept of abstraction?

Abstraction (from the Latin abs, meaning away from and trahere , meaning to draw) is the process of taking away or removing characteristics from something in order to reduce it to a set of essential characteristics.

What does closed modification mean?

In object-oriented programming, the open–closed principle states "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification"; that is, such an entity can allow its behaviour to be extended without modifying its source code.

What is abstraction in research?

A cognitive process in which common elements of diverse things are identified and pulled out of their context (abstracted) in order to study them. Doing this makes it possible to classify and analyze ∗data that could not otherwise be studied together.

What is abstraction and why is it important?

Abstraction is one of the key concepts of object-oriented programming (OOP) languages. Its main goal is to handle complexity by hiding unnecessary details from the user.


2 Answers

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.
like image 98
Lee Louviere Avatar answered Sep 27 '22 18:09

Lee Louviere


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.

like image 21
K'' Avatar answered Sep 27 '22 18:09

K''