Answer the question
In order to leave comments, you need to log in
What is abstraction?
What exactly do developers mean by "Abstraction" when it comes to OOP?
Abstraction can be called some entity that is not a reflection of the object of the real world (as with abstract art, something "abstract"). Example - Pure fiction from GRASP.
Also, in principle, any class can be called an abstraction, because classes in software have only the detail that is necessary in the context of the task that the software is solving. Those. this is something that has only the functions necessary in the context of the task, the rest is omitted.
Another abstraction can be called, for example, an interface. Interface methods do not contain an implementation, they only describe how an entity that implements this interface can be interacted with. Those. in this context, abstraction is a certain outline, a sketch that does not contain specifics.
You read forums, books, chats, articles, and the thought does not leave you that developers in OO languages communicate like 2 smart speakers placed side by side. It seems that they are saying something, but the feeling that they are talking about different things, because everyone builds an idea regarding their understanding of terminology, including abstraction.
Answer the question
In order to leave comments, you need to log in
I do not pretend to be the ultimate truth, but in my head it looks like this:
Abstraction is some kind of generalization. For example, there is a cat, a dog and a parrot. We can introduce the abstraction "pets". By adding a wolf and a lynx to this design, we can introduce the abstraction "wild animals". And then introduce the abstraction "animals". And then "living beings", etc.
In object-oriented programming, abstractions take the form of abstract classes and interfaces.
In generic programming, abstractions take the form of template classes and functions.
In functional programming, abstractions take the form of higher-order functions.
"Pure fiction" - from my point of view, this is not an abstraction, it is just a way of separating responsibility into a separate class. But this very responsibility is quite specific.
Classes are not an abstraction. In any modeling, we transfer the essential features of the simulated phenomenon (system) into the model and discard the non-essential ones. What you are talking about is the inevitable loss of detail when building a model.
An abstract class in OOP is an incomplete class, from which an object cannot be created, because not everything is described.
For example, as already mentioned in the answers, let's take the "animal" class. We can describe in it things that are common to all animals, such as methods of movement or properties "species" or "biological class". We cannot initialize such an object, because there is no mere "animal" being. But the inherited class "dog" from the abstract class "animal" can be created. At the same time, we can have one list of "animals" and access the common methods and properties that are described in the abstract class.
An abstract class, like an interface, requires the child class to implement everything that is described in the abstract class, but not implemented, however,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question