Code Smells
Warning signs in code — learn to spot them early.
22 lessons · follow them in order, or jump to what you need.
Long Method: When One Function Tries to Do Everything
Learn the Long Method code smell with simple stories, TypeScript and C# examples, and step-by-step refactoring using Extract Method. Beginner friendly guide.
Large Class: The School Bag That Carries Everything
Understand the Large Class code smell — why god classes grow, how to spot low cohesion, and how Extract Class splits them into small, focused classes.
Primitive Obsession: When Everything Is Just a String or a Number
Primitive Obsession explained simply — why plain strings and numbers hide bugs, and how value objects like Money and Address make code safe and clear.
Long Parameter List: The Chai Order That Took Ten Instructions
Long Parameter List code smell made simple — why methods with too many arguments cause bugs, and how parameter objects make calls short, clear, and safe.
Data Clumps: The Friends Who Always Travel Together
Data Clumps code smell for beginners — learn to spot groups of values that always travel together and bundle them into one class, like a student ID card.
Switch Statements: The Receptionist With the Giant Rulebook
Learn the Switch Statements code smell with a school receptionist story, duplicated switch examples in TypeScript and C#, and the polymorphism cure.
Temporary Field: The Cricket Kit That Lives in the School Bag
Learn the Temporary Field code smell with a school bag story, see null-filled fields in TypeScript and C#, and fix them with Extract Class step by step.
Refused Bequest: The Child Who Refused the Sweet Shop Recipes
Learn the Refused Bequest code smell with a family sweet shop story, Liskov violations in TypeScript and C#, and the delegation cure explained step by step.
Alternative Classes with Different Interfaces: Two Tiffin Services, Two Languages
Learn this code smell with a tiffin delivery story: two classes do the same job with different method names, so you cannot swap them. Fix it step by step.
Divergent Change: One Poor Clerk, Too Many Bosses
Learn the Divergent Change code smell with a school clerk story, simple definitions, TypeScript and C# examples, a clear comparison with Shotgun Surgery, and practice.
Shotgun Surgery: One Small Change, Ten Offices to Visit
Learn the Shotgun Surgery code smell with an address-change story, simple definitions, TypeScript and C# examples, a clear comparison with Divergent Change, and practice.
Parallel Inheritance Hierarchies: Every Sweet Needs Its Shadow Box
Learn the Parallel Inheritance Hierarchies code smell with a sweet-shop story, mirrored class trees explained simply, TypeScript and C# examples, fixes, and practice.
Comments Smell: When Sticky Notes Hide a Messy Cupboard
Learn why too many comments can be a code smell. Understand good WHY comments vs bad WHAT comments with a sticky-note cupboard story and easy examples.
Duplicate Code: Writing the Same Address on 50 Wedding Cards
Learn the Duplicate Code smell with a wedding card story. Understand DRY, the Rule of Three, and how Extract Method removes dangerous copy-paste code.
Lazy Class: The Watchman Whose Only Job Is Pressing One Lift Button
Learn the Lazy Class code smell with a society watchman story. Find classes that do too little to deserve existing, and cure them with Inline Class.
Data Class: The Register With No Rules — Anyone Can Scribble Anything
Learn the Data Class smell with a society register story. See why data without behavior breaks encapsulation, and when DTOs and records are perfectly fine.
Dead Code: Old Furniture Blocking the Storeroom 'Just in Case'
Learn the Dead Code smell with a storeroom full of unused furniture. See why unreachable code costs real money, with the Knight Capital story and easy fixes.
Speculative Generality: Plumbing for a Swimming Pool You May Never Build
Learn the Speculative Generality smell with a house-building story. Understand YAGNI, why guessing future needs backfires, and how to collapse unused abstractions.
Feature Envy: The Method That Sits in Someone Else's Class All Day
Learn the Feature Envy code smell with a simple school story. When a method keeps using another class's data more than its own, it probably belongs in that other class. Cure it with Move Method.
Inappropriate Intimacy: Two Classes That Walk Into Each Other's Kitchens
Learn the Inappropriate Intimacy code smell with a story of two neighbours who rearrange each other's kitchens. When two classes poke each other's private parts, neither can change alone. Learn the Law of Demeter and the refactorings that restore privacy.
Message Chains: Asking a Friend, Who Asks a Cousin, Who Asks an Uncle
Learn the Message Chains code smell with a story about finding out if bread is available — through four people. When code reads a.getB().getC().getD(), the caller is coupled to a whole path. Learn the Law of Demeter and cure chains with Hide Delegate.
Middle Man: The Helper Who Only Forwards Your Message to the Principal
Learn the Middle Man code smell with a story of a school helper who only carries messages without adding anything. When a class merely forwards every call, remove it — but learn why Proxy, Facade, and Adapter are middle men ON PURPOSE.