An old man dies of a heart attack. What do we choose as the explanation for his death?
We could simply say he died of a heart attack and leave it at that. Or we could say that his brain activity ceased due to lack of oxygen to the brain. Or we could say that he died of old age. All of these explanations are valid and appropriate depending on the level of detail we’re interested in.
When we replace lower-level information with higher-level information in order to work with a certain subject more easily, it’s called abstraction.
Abstraction is a process. Carrying out the process of abstraction can result in an entity called an abstraction. (Note the two meanings of the same word.) An abstraction is a model of some part of the world at a certain level of detail.
Imagine two computer programs, one that tracks local obituaries and another that tracks clinical details of patients. In the obituary program, it would probably be appropriate to have an abstraction called “individual” and list a person’s death at a high level of abstraction, e.g. heart attack. In the clinical program, it might be more appropriate to have an abstraction called “patient” and describe the patient’s cause of death at a much lower level of abstraction. Both abstractions refer to the same entity, a person, but at different levels of detail, different levels of abstraction.
The root of abstraction is abstract. One definition of abstract is “existing in thought or as an idea but not having a physical or concrete existence”. Another similar definition of abstract is “not having to do with any particular instance”. Confusingly, abstractions don’t have to be particularly abstract. There’s nothing abstract about saying “Michael Jackson died of a heart attack” for example. In fact it’s quite concrete. Nor do abstractions have to be generalizations.
Sadly, the prevailing understanding of abstraction in the programming community seems to be “a thing that is abstract”. Abstraction has come to mean generalization. But that’s mistaken. Abstraction is not mainly about generalization, it’s about dealing with concepts at an appropriate level of detail.