Roadmap › Clean Code, Testing & Best Practices › Module: Code Smells and Refactoring
Lessons in this course (12)

5. Common code smells

Intermediate★ Must knowLesson 5 of 12
SmellSymptomRefactoring
Long method> ~30 lines, many comments explaining blocksExtract Method
Large class / God classMany responsibilities, 1000+ linesExtract Class (SRP)
Long parameter list5+ paramsIntroduce Parameter Object
Duplicated codeSame logic in many placesExtract Method/Class, DRY
Switch on typeswitch (type) repeatedReplace Conditional with Polymorphism (Strategy)
Feature envyMethod uses another class's data more than its ownMove Method
Primitive obsessionstring email, decimal amount + string currency everywhereValue objects (Email, Money)
Shotgun surgeryOne change edits many filesMove related code together
Dead codeUnused methods/paramsDelete
Magic numbersif (status == 3)Enum/constant