Explore the Catalog
String processOrder(String item, int qty, boolean isMember, String country) { if (item == null || item.isEmpty()) return "ERROR"; if (qty <= 0) return "ERROR"; double price; if (item.equals("book")) price = 12.0; else if (item.equals("pen")) price = 1.5; else return "ERROR"; double sub = price * qty; double disc = 0; if (isMember && sub > 100) disc = sub * 0.10; else if (isMember) disc = sub * 0.05; double ship = country.equals("US") ? 5 : 25; if (sub - disc > 200) ship = 0; return "OK " + (sub - disc + ship);}Brown, Malveau, McCormick, and Mowbray coined the term in AntiPatterns (Wiley, 1998) as the deliberate counterpart of the GoF design-pattern catalog. Where a design pattern starts with a well-defined problem and maps to a tried-and-true solution, an antipattern starts with a poorly defined situation and maps to a tempting-looking solution that always turns out to be a mistake. The antipattern record looks almost identical to a GoF record — Name, Context, Problem, Symptoms, Consequences — except that the closing slot says Refactoring (the way out) instead of Known Uses. A code smell (Kent Beck, popularised by Fowler) is the lower-rung cousin: a hint that an antipattern may be lurking, surfaced by something visible in the code (a 300-line method, a parameter list of nine booleans, a class named Manager).
- A design pattern catalogs a good recurring solution; an antipattern catalogs a recurring mistake plus the way back to safety.
- The six-part anatomy mirrors the GoF record: Name, Type (Dev / Architecture / Project-Management), Problem, Symptoms, Consequences, Refactoring.
- A code smell is observable in the code itself (LOC, parameter count, duplication). It is the signal; the antipattern is the diagnosis.
- Antipatterns span three categories — Development (Spaghetti, God Class), Architecture (Stovepipe, Big Ball of Mud), Project Management (Death March, Analysis Paralysis).
- The cure is almost always a positive pattern or principle you already know — SRP, ISP, DRY, DI, Strategy, Extract Method.
- ★Naming bad patterns creates a shared vocabulary — "this is a God Class" is faster than a five-minute critique.
- ★Documented refactoring paths transfer expertise from senior to junior developers without an in-person mentor.
- ★Categorising by Development / Architecture / Project-Management makes the right team responsible for the fix.
- ★Reading the antipattern catalog before writing code lets you avoid mistakes you have never personally made.
- △Labels can become buzzwords — calling everything "spaghetti" loses the diagnostic edge.
- △Misdiagnosing a legitimate design as an antipattern can be more harmful than the smell itself.
- △Categories overlap — a God Class is also a Spaghetti Method and an SRP violation, depending on which axis you measure on.