Code Smell¶
Treat an observable feature of code as defeasible evidence of a deeper design or maintainability problem—not proof of a defect—so inspection triggers a context test and a refactoring hypothesis.
Core Idea¶
A code smell is an observable feature of source code that provides defeasible evidence of a deeper design or maintainability problem. It is deliberately weaker than a bug or violated rule. A long parameter list, passive data class, misplaced method, temporary field, or speculative abstraction can be entirely correct at runtime; the surface pattern matters because experience associates it with hidden coupling, misplaced responsibility, duplicated knowledge, or needless change cost.
The defining workflow is notice → hypothesize → test → refactor or acquit. The smell names a trace and a candidate diagnosis. Context then decides whether the trace reflects an actual design problem: a data-only record may be intentional, a long parameter list may express irreducible inputs, and an apparently lazy class may preserve a valuable boundary. If the hypothesis survives, a small refactoring should improve the predicted maintenance property without changing behavior. If it does not, the code is acquitted and the surface is not a smell in that context.
Scope of Application¶
Code smell belongs to software design, code review, maintenance, and refactoring across languages and paradigms. Specific catalogs differ, but the defeasible trace-to-design-hypothesis relation remains stable.
Clarity¶
The abstraction prevents two opposite errors: treating every catalog match as a defect, and dismissing a non-failing pattern as mere taste. A smell is evidence worth investigating, not proof worth mechanically prosecuting.
Knowledge Transfer¶
The named concept stays in software because its traces, hypotheses, and interventions concern program representations and refactoring. Its portable parent is evidence: an observable trace supports a defeasible claim about a less directly visible state.
Relationships to Other Abstractions¶
Current abstraction Code Smell Domain-specific
Parents (1) — more general patterns this builds on
-
Code Smell is a kind of Evidence Prime
A code smell is defeasible evidence specialized to observable source-code features that support a hypothesis about a deeper design or maintainability problem.
Children (9) — more specific cases that build on this
-
Comments as Deodorant Domain-specific is a kind of Code Smell
Comments as Deodorant is the meta-level code smell in which explanatory prose suppresses the visible trace that should have triggered structural investigation and refactoring.
-
Data Class Domain-specific is a kind of Code Smell
Data Class is the code-smell species whose passive fields and accessors provide defeasible evidence that behavior and invariant enforcement migrated into consumers.
-
Feature Envy Domain-specific is a kind of Code Smell
Feature Envy is the code-smell species whose cross-class access pattern provides defeasible evidence that a method's responsibility resides on the wrong class.
-
Lazy Class Domain-specific is a kind of Code Smell
Lazy Class is the code-smell species whose low responsibility-to-overhead ratio suggests that an abstraction boundary has not earned its maintenance cost.
-
Long Parameter List Domain-specific is a kind of Code Smell
Long Parameter List is the code-smell species whose high-arity call boundary provides defeasible evidence that hidden co-variation structure was offloaded onto callers.
- Primitive Obsession Domain-specific is a kind of Code Smell
Primitive Obsession is the code-smell species whose repeated use of bare built-ins provides defeasible evidence that warranted domain distinctions are missing from the type representation.
- Refused Bequest Domain-specific is a kind of Code Smell
Refused Bequest is the code-smell species whose stubs, throws, or ignored inherited members provide defeasible evidence that inheritance was used for reuse despite a broken subtype contract.
- Speculative Generality Domain-specific is a kind of Code Smell
Speculative Generality is the code-smell species whose unused flexibility provides defeasible evidence that anticipated variation imposed present complexity before earning it.
- Temporary Field Domain-specific is a kind of Code Smell
Temporary Field is the code-smell species whose always-present field provides defeasible evidence that structural scope exceeds the state item's validity scope.
Hierarchy paths (4) — routes to 4 parentless roots
- Code Smell → Evidence → Provenance → Traceability → Observability
- Code Smell → Evidence → Provenance → Attestation → Authentication
- Code Smell → Evidence → Provenance → Traceability → Transformation → Function (Mapping)
- Code Smell → Evidence → Provenance → Custody Transfer → State and State Transition → Phase Space
References¶
- Fowler, M. (1999/2018). Refactoring: Improving the Design of Existing Code.
- Beck, K., & Fowler, M. (1999). Bad smells in code. In Refactoring.
- Mäntylä, M. V. (2003). Bad Smells in Software—A Taxonomy and an Empirical Study.