Object Oriented ABAP Generalization, Specialization and Inheritance

Inheritance is an important concept of Object-Oriented programming. But, to really understand the importance of inheritance, you need to first understand the concept of Generalization and Specialization.

Inheritance

The general concept of Inheritance is : a class ( known as subclass ) inherits another class ( known as superclass ). In Inheritance, the subclass inherits all the characteristics (or in another words, all the components) of the superclass. The subclass can further add new components and even replace the implementation of inherited methods.

That said, why do we really need Inheritance? This we will understand by understanding the importance of Generalization and Specialization in software development.

Generalization and Specialization

When following object-oriented approach to software development, generalization and specialization gives foundation to better software structure. Common characteristics are defined and maintained centrally in superclass, a generalized class. Subclass inherits all the main characteristics and can also add new components, referred as specialization. Generalization and specialization also take care of avoiding duplicate implementations.

Specialization is also termed as an “is a” relationship sematically.

In the below example, vehicle is a superclass that holds common characteristics of a vehicle. Car, Bus and Truck is inheriting superclass vehicle as well as adds their own specialized components.