- Refactoring
- Smells: dead weight
Smells: dead weight
Code smells in code that adds nothing: duplicated, unused or speculative.
6 guides39 min in totalRefactoring
The guides, in order
Read them top to bottom: each one builds on the ones before. The ones you've read carry a check.
- Duplicate Code: When the Same Logic Lives in Several PlacesHow to spot duplicated logic that drifts apart between copies, why it causes real bugs, and which refactorings merge it back into one place.5 min readStart here
- Dead Code: Unused Functions, Branches and FlagsHow to spot code that never runs, like unused functions, unreachable branches and permanently-off flags, and how to delete it safely.7 min read
- Speculative Generality: Abstractions Built for Needs That Never CameHow to spot interfaces, hooks, parameters and factories written for imagined future requirements, and how to strip them back to what the code actually needs.7 min read
- Lazy Class: When a Class Doesn't Earn Its PlaceHow to spot a lazy class that wraps a single line or forwards one call, why it appears, and when to inline it or keep it.6 min read
- Data Class: Fields and Getters With the Logic Living ElsewhereHow to spot a data class that only holds fields and accessors, why it scatters business rules, and how to move behaviour back next to the data.7 min read
- Explaining Comments: When a Comment Covers for Unclear CodeHow to spot comments that narrate what confusing code does, and how to refactor the code so the comment becomes unnecessary.7 min read
About this group
- What you'll find
- Duplicate code, dead code, lazy class, data class, speculative generality and explaining comments.
- It's for you if…
- the code is full of copies, just-in-case abstractions or functions nobody dares to delete.
- How each guide works
- Smell guides cover the signs, an example, why it happens, the treatment with its refactorings, what you gain and when it's not worth fixing. Technique guides show the problem, the code before and after, the steps, which smells it removes, its benefits and its cautions.
More groups in Refactoring
- Smells: bloatCode smells in code that has grown so much it can no longer be understood at a glance.See the 5 guides
- Smells: rigidityCode smells where one change forces many others, far away: divergent change, shotgun surgery, and the refactorings that cure them.See the 3 guides
- Smells: couplingCode smells in pieces that know too much about each other: feature envy, inappropriate intimacy, message chains, and how to decouple them.See the 5 guides
- Smells: misused abstractionsCode smells where inheritance, types or conditionals are used against the grain.See the 4 guides
- Techniques: composing functionsRefactorings that split long functions into named pieces, or undo pieces that add nothing.See the 7 guides
- Techniques: organizing dataRefactorings that give data a name, a type and a single purpose: replace primitives and magic numbers, encapsulate fields and collections.See the 5 guides
- Techniques: simplifying callsRefactorings that make a function's signature say what it does and make it easy to use correctly.See the 4 guides
- Techniques: simplifying conditionalsRefactorings that make conditional logic readable at a glance: guard clauses, decomposed conditions and polymorphism instead of switches.See the 5 guides
- Techniques: moving featuresRefactorings that move each responsibility to the class or module where it belongs.See the 5 guides