Class with Excessive Number of Child Classes

Incomplete Base
Structure: Simple
Description

This weakness occurs when a parent class has an excessive number of child classes that inherit from it, creating a deep and overly complex inheritance tree.

Extended Description

An inheritance hierarchy with too many child classes becomes difficult to understand, navigate, and maintain. This complexity slows down development and code reviews, making it harder to spot logic errors, security flaws, or unintended side-effects when changes are made. The increased cognitive load on developers indirectly raises security risks, as vulnerabilities can be more easily introduced and are more time-consuming to find and fix. While the specific threshold for "excessive" can vary by project, the CISQ (Consortium for IT Software Quality) recommends a default maximum of 10 direct child classes for a single parent. Adhering to this guideline helps maintain a cleaner, more modular design, promoting code that is easier to secure and audit. Consider refactoring through techniques like composition or creating intermediate abstract classes to flatten overly deep hierarchies.

Common Consequences 1
Scope: Other

Impact: Reduce Maintainability

References 1
Automated Source Code Maintainability Measure (ASCMM)
Object Management Group (OMG)
01-2016
ID: REF-960
Taxonomy Mapping
  • OMG ASCMM