What is abstraction in OOP?

Abstraction in OOP Theory consists in retaining only the relevant aspects of a real world object for a specific problem.

Thus we talk about abstraction of the reality.

It's a reduction.

For example, in the real world we have cats and dogs that are vertebrate animals. Such an animal has properties such as head and legs, and operations like walking and eating. We will then define classes that will be Animal and Cat and Dog.

So we have the concept of inheritance where the cat and the dog inherits properties and operations that are common and that we will then put at the level of animal to not repeat these elements in the children class: that is the generalization. Also cats can meow and dogs can bark: that is the specialization.

Abstraction is thus a projection of the real world into a more limited conceptual world.

Doing abstraction is identifying the properties and behaviors we need to design a computer system and therefore software, and we reject all that we don't need.

For example, in a banking system, we identify customer that have a name, an address and so on. We take all things necessary and reject others like how they eat or how they walk or what is the last book they read.

Absraction is defining the needed concepts (the entities and their aspects and their behaviors and their relations) and forgot what is not needed.

It's a section of reality.

We name class a concept that comes from the abstraction and object an instance of this concept within the software domain that will run on a computer that is thus a materialization.

All others OOP terms are vocabulary to define the means to do that.

For example encapsulation is the process to mask some properties and operations in the class that will become inaccessible from the exterior: these are only internal things and behaviours like a digestive system.

There is also polymorphism and interfaces in addition to classes.

Here are some Wiktionary definitions:

The act of abstracting, separating, withdrawing, or taking away; withdrawal; the state of being taken away.

The act of focusing on one characteristic of an object rather than the object as a whole group of characteristics; the act of separating said qualities from the object or ideas.

The act of comparing commonality between distinct objects and organizing using those similarities; the act of generalizing characteristics; the product of said generalization.

(Computing) Any generalization technique that ignores or hides details to capture some kind of commonality between different instances for the purpose of controlling the intellectual complexity of engineered systems, particularly software systems.

(Computing) Any intellectual construct produced through the technique of abstraction.

Links

CC BY-SA 4.0 Original Post