What are the Risks associated with Inheritance in Classes?

One of the important features of Object-oriented languages is inheritance.
It consists of a base or a generic class, and one or multiple classes called “derived” classes which “inherit” from it.

Usefulness of generic classes

  • Minimizes duplicity
    Methods and datatypes encapsulated within a generic class can be reused – without duplicity and redundancy
  • Maps real-world objects and relationships into abstract coding components
    Generic class: Class Person { lastname, firstname, date of birth, phone number, address, email-id}
    Derived Class 1: Class Employee { <everything from Class Person> + Social Security Number, Employee Id, Salary…}
    Derived Class 2: Class Employee { <everything from Class Person> + Student Id…}
  • Extensibility
    The generic class can be “extended” and the derived class can build on a strong foundation.

Dangers of generic classes

  • Errors, flaws, vulnerabilities are all inherited
    If the generic class was built with undetected errors, flaws, and vulnerabilities, all the classes inheriting from it are not secure – and it scales up the security risk of the entire software rapidly.
  • Inflexibility
    The generic classes and the child class are tightly coupled. The program is “burdened by methods and behavior defined in a more general superclass, making down-the-line changes and customization difficult”.
    If a design needs to be changed or adapted this involves a lot of tweaking and restructuring in the original code and can open a plethora of problems.
  • Multiple inheritances
    When a child class inherits from more than one generic class, it magnifies the complexity and the problems associated with inheritance. The “deadly diamond problem” is a notorious multiple-inheritance risk.


  1. Hill, M. (2011, May 6). What are the main disadvantages of inheritance in object-oriented programming, and why? Retrieved from https://www.quora.com/What-are-the-main-disadvantages-of-inheritance-in-object-oriented-programming-and-why
  2. Multiple-inheritance. (2017, January 27). Retrieved from https://en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem