Base Class depends on Subclass — Code Smells Catalog Skip to content

Base Class depends on Subclass

Also known as: Base Classes Depending on Their Derivatives

Object Oriented Abusers Interfaces AntipatternCode SmellDesign Smell Between Class

When a parent class reaches down to reference its own children, the inheritance tree grows upside down. Change a leaf, redeploy the trunk.

1 min read 1 source

Overview

The rule is that the child classes should be deployable independently from the parent class. That allows us to deploy the system in discrete and independent components.

When one of these subclasses is modified, the base class does not need to be redeployed as well. In this way, the impact of change is much smaller, proportionally to the maintenance effort [1]. This smell is closely related to the Shotgun Surgery code smell.

Problems

Liskov Substitution Principle Violation

Base class and Subclass should be interchangeable without breaking the logic of the program. ---

Sources

Browse All 56 Smells