What is a 'code smell' in software engineering vocabulary?
Code smell (term coined by Kent Beck, popularized by Martin Fowler's Refactoring) is a symptom in source code suggesting deeper structural problems. Smells are not bugs — the code may work correctly — but they make code harder to understand, maintain, and extend.
2 / 5
What is a 'long method' code smell?
Long Method is one of Fowler's most common smells. Methods should do one thing. A method exceeding 10–20 lines often does multiple things and should be decomposed using Extract Method. Long methods are harder to name accurately, test, reuse, and understand.
3 / 5
What is 'feature envy' as a code smell?
Feature Envy: a method in class A that mostly uses data from class B suggests the method belongs in class B. The fix is typically Move Method — move the method to the class whose data it is most interested in.
4 / 5
What is 'primitive obsession' as a code smell?
Primitive Obsession: using String for phone numbers, float for currency, int for status codes — when a class (PhoneNumber, Money, OrderStatus) would better express intent, enforce invariants, and enable domain-specific behavior. The fix is Replace Data Value with Object.
5 / 5
What is 'shotgun surgery' as a code smell?
Shotgun Surgery: a single change requires modifying many classes. This is the inverse of Divergent Change. It indicates related behavior is spread across the codebase instead of being concentrated. The fix is to use Move Method/Field to consolidate related behaviors into a single class.