Code smells are surface indicators that suggest deeper design problems in software systems — they're not bugs, but warning signs of maintainability issues, technical debt, and architectural decay. First coined by Kent Beck and popularized by Martin Fowler, these patterns help developers identify when code needs refactoring. Anti-patterns, by contrast, are common solutions that initially appear reasonable but lead to negative consequences — often arising from organizational pressures, misapplied design patterns, or lack of understanding. The key insight: both code smells and anti-patterns are symptoms, not diseases — they point to underlying structural problems that, if addressed early, prevent systems from becoming unmaintainable legacy codebases.
What This Cheat Sheet Covers
This topic spans 11 focused tables and 58 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Fowler's Bloater Code Smells
| Smell | Example | Description |
|---|---|---|
def processOrder(): # 200 lines of code # mixing validation, calculation, # database access, logging... | • Method exceeds 10-15 lines and does too many things • harder to understand, test, and reuse. | |
class OrderManager: # 50 fields # 100+ methods # handles orders, payments, # shipping, inventory... | • Class has too many responsibilities and fields • violates Single Responsibility Principle. | |
createUser(name, email, age, addr, city, zip, country, phone, fax, company) | • More than 3-4 parameters make methods hard to call and understand • often signals missing object abstraction. |