Code Smell 323 - Harness-Driven Superclass
You didn't split the class. You hid half of it upstairs

TL;DR: Don't create a superclass just to pass a size limit. Move behavior into collaborators with delegation.
Problems π
- Inheritance without a real specialization
- Hidden coupling to the superclass
- Yo-yo navigation across files
- Fragile base class
- Vague parent names
- Responsibilities stay in one object
- Bijection violation
Solutions π
- Extract cohesive collaborators
- Delegate, don't inherit
- Split by responsibility
- Name by domain concept
- Measure cohesion, not size
Refactorings βοΈ
https://maximilianocontieri.com/refactoring-023-replace-inheritance-with-delegation
https://maximilianocontieri.com/refactoring-007-extract-class
Context π¬
A harness caps class length, property count, and method count, and it rejects code that goes over.
Some limits work as good alarms for growing responsibilities (long functions, too many attributes, too many methods).
You ask an AI assistant to make the failing class pass.
The shortest path is moving half of its members into a new parent class.
The count per class drops, the check turns green, and nothing else changes.
The behavior stays in the same object, because the child inherits everything the parent holds.
Developers did this for years to dodge size rules in code reviews.
Now the assistant does it in seconds, and it stacks as many layers as the harness needs.
The parent has no meaning of its own, so it gets names like Base, Part, or Abstract.
You use inheritance to share code, not to model a specialization.
Johnson and Foote suggested factoring shared behavior into abstract superclasses back in 1988, and that advice fits frameworks that share real protocols, not size quotas.
The metric improves and the design gets worse.
That's Goodhart's law at work.
Sample Code π»
Wrong π«
// The harness rejects over 300 lines, 10 attributes or 20 methods.
//
// The agent that tries to prove the Riemann Hypothesis kept
// growing: every new theory and sublemma added methods and
// state to it.
//
// To pass the harness, the assistant moved the overflow
// into superclasses that exist only to hold members.
abstract class ProofBase {
protected lemmas = new Set<string>();
protected log: string[] = [];
// 300 attributes more
protected record(step: string): void {
this.log.push(step);
}
protected assume(claim: string): void {
this.lemmas.add(claim);
}
}
abstract class EulerProductPart extends ProofBase {
protected eulerProduct(s: number): number {
this.record(`euler product at ${s}`);
return 0; // ...
}
protected primeCounting(n: number): number {
return 0; // ...
}
}
abstract class FunctionalEquationPart extends EulerProductPart {
protected reflect(s: number): number {
return 1 - s;
}
protected xiSymmetry(s: number): boolean {
return true; // ...
}
}
abstract class ZeroSearchPart extends FunctionalEquationPart {
protected knownZeros: number[] = [];
protected verifyZerosUpTo(height: number): boolean {
return true; // ...
}
}
class RiemannProofAgent extends ZeroSearchPart {
prove(): boolean {
this.assume("zeros lie in 0 < Re(s) < 1");
this.eulerProduct(2.0);
this.xiSymmetry(0.5);
return this.verifyZerosUpTo(1e12);
}
// 300 methods more
}
Right π
class LemmaLedger {
private lemmas = new Set<string>();
private log: string[] = [];
record(step: string): void {
this.log.push(step);
}
assume(claim: string): void {
this.lemmas.add(claim);
}
}
class EulerProduct {
constructor(private readonly ledger: LemmaLedger) {}
evaluateAt(s: number): number {
this.ledger.record(`euler product at ${s}`);
return 0; // ...
}
primeCounting(n: number): number {
return 0; // ...
}
}
class FunctionalEquation {
reflect(s: number): number {
return 1 - s;
}
checkSymmetryAt(s: number): boolean {
return true; // ...
}
}
class ZeroVerification {
private knownZeros: number[] = [];
verifyUpTo(height: number): boolean {
return true; // ...
}
}
class RiemannProofAgent {
constructor(
private readonly ledger: LemmaLedger,
private readonly eulerProduct: EulerProduct,
private readonly functionalEquation: FunctionalEquation,
private readonly zeroVerification: ZeroVerification
) {}
prove(): boolean {
this.ledger.assume("zeros lie in 0 < Re(s) < 1");
this.eulerProduct.evaluateAt(2.0);
this.functionalEquation.checkSymmetryAt(0.5);
return this.zeroVerification.verifyUpTo(1e12);
}
}
Detection π
[X] Semi-Automatic
Search for abstract classes with a single subclass that no code uses as a type.
If nobody type-hints the parent, it exists only to hold members.
Look for parent names like Base, Part, Helper, or Abstract, and for hierarchies that got deeper right after you introduced a size limit.
Check the history: a failed size check followed by a commit that adds a parent and moves members up is the signature.
Exceptions π
A parent class is fine when several subclasses share a real protocol and callers depend on the parent type.
In that case, the parent models a concept, and you can explain it without mentioning the size limit.
Tags π·οΈ
- Hierarchies
Level π
[x] Intermediate
Why the Bijection Is Important πΊοΈ
Every class in your model should match a concept in the MAPPER.
A parent class created to hold overflow members matches nothing.
Nobody in the domain would say "this thing is a kind of leftover bucket".
When you delegate to collaborators, each one maps to a concept you can name, and the bijection stays intact.
When you hide members upstairs, the original object keeps every responsibility, and you add coupling between the layers.
AI Generation π€
AI generators create this smell often when you ask them to respect a size limit.
They optimize for the check you gave them, and moving members into a parent is the smallest diff that turns it green.
They don't stop to ask whether the new parent models anything.
Humans took this shortcut when they felt the pressure of a review rule, but an assistant takes it on every failing class, without hesitation and without feeling any shame.
AI Detection π§²
AI can detect it if you point it at the pattern.
Try: "Find abstract classes with a single subclass that no code uses as a type, and explain what concept each one models."
Without that prompt, the hierarchy looks tidy, the harness passes, and most assistants won't flag the code they just wrote.
Try Them! π
Remember: AI Assistants make lots of mistakes
Suggested Prompt: Replace the intermediate superclasses that only hold overflow members with collaborator objects, and delegate to them from the original class
| Without Proper Instructions | With Specific Instructions |
|---|---|
| ChatGPT | ChatGPT |
| Claude | Claude |
| Perplexity | Perplexity |
| Copilot | Copilot |
| You | You |
| Gemini | Gemini |
| DeepSeek | DeepSeek |
| Meta AI | Meta AI |
| Grok | Grok |
| Qwen | Qwen |
Conclusion π
A size limit is an alarm, not a design.
When the alarm rings, split the responsibilities instead of moving them to a parent.
Delegate to small objects you can name, test, and replace.
Don't let the assistant pass the harness by hiding the mess one floor up.
Relations π©ββ€οΈβπβπ¨
https://maximilianocontieri.com/code-smell-11-subclassification-for-code-reuse
https://maximilianocontieri.com/code-smell-58-yo-yo-problem
https://maximilianocontieri.com/code-smell-136-classes-with-just-one-subclass
https://maximilianocontieri.com/code-smell-14-god-objects
https://maximilianocontieri.com/code-smell-147-too-many-methods
https://maximilianocontieri.com/code-smell-34-too-many-attributes
https://maximilianocontieri.com/code-smell-320-vanity-coverage
https://maximilianocontieri.com/code-smell-313-workslop-code
More Information π
Replace Inheritance with Delegation
The same trick works against any metric you can game, like coverage or line count.
Quote
When a measure becomes a target, it ceases to be a good measure.
Marilyn Strathern
Disclaimer π
Code Smells are my opinion.
Credits π
This article is part of the CodeSmell Series.
https://maximilianocontieri.com/how-to-find-the-stinky-parts-of-your-code
About the author
Iβm a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.
Comments
Join the discussionNo comments yet. Be the first to comment.
Code Smells
In this series, we will see several symptoms and situations that make us doubt the quality of our developments. We will present possible solutions. Most are just clues. They are no hard rules.




