- Refactoring
- Smells: bloat
Smells: bloat
Code smells in code that has grown so much it can no longer be understood at a glance.
5 guides30 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.
- Long method: when one function does the whole jobHow to spot a function that has grown too long, why it happens, and the refactorings that split it into pieces you can read and test.5 min readStart here
- Large ClassA Large Class collects unrelated fields and responsibilities until no one can change one part without reading all of it.7 min read
- Long Parameter ListHow to spot functions that take too many positional arguments, especially boolean flags, and the refactorings that make their call sites readable again.6 min read
- Primitive Obsession: when strings and numbers fake domain conceptsPrimitive Obsession is when raw strings, integers and floats stand in for money, ids, emails and date ranges, scattering validation and rules across your code.6 min read
- Data ClumpsHow to spot groups of values that always travel together through your signatures, and how to turn them into a single object with its own behaviour.6 min read
About this group
- What you'll find
- Long method, large class, long parameter list, data clumps and primitive obsession.
- It's for you if…
- you review functions hundreds of lines long and don't know how to justify where to cut them.
- 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: 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: dead weightCode smells in code that adds nothing: duplicated, unused or speculative.See the 6 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