Skip to main content

Smell Identification Clinic

Retrieval Prompts

  1. List at least 10 smells from Fowler's catalog from memory.
  2. Pair each smell with its canonical refactoring move.
  3. State the difference between Divergent Change and Shotgun Surgery.
  4. State the difference between a Long Method and a long, cohesive pure calculation.
  5. Explain why Speculative Generality is the counterweight to Replace Conditional with Polymorphism.

Compare and Distinguish

Separate these pairs:

  • Divergent Change vs Shotgun Surgery
  • Feature Envy vs Data Clump (sometimes the same move fixes both)
  • Primitive Obsession vs genuine use of primitives for primitive data
  • Repeated Switch vs a single switch in a central dispatcher
  • Speculative Generality vs justified abstraction with two existing variants

Common Mistake Check

For each diagnosis, identify the error:

  1. "This method is 80 lines, so it is a Long Method." (What's missing?)
  2. "This class has 15 public methods, so it violates SRP." (When is that fine?)
  3. "We use switch here, so we should replace it with polymorphism." (What evidence is missing?)
  4. "The interface has four methods; three clients use all four, one uses only one. That is an ISP violation." (Is it?)
  5. "Every new Payment subclass needs a matching PaymentValidator subclass. That's Parallel Hierarchies, so let's collapse both." (What should you check first?)

Mini Application

Three exercises, all required.

Exercise 1: Smell hunt on a real file

Pick any real file over 150 lines (ideally from an unfamiliar repo). Do all of:

  1. List every smell you find, with a short quote of the evidence.
  2. Rank them by pain-of-next-change (which one will bite you first?).
  3. Pair each smell with a refactoring move.
  4. Choose the top three to fix and justify the ordering.

Exercise 2: Change-based smells

Pick a recent feature branch. Do all of:

  1. List every file the branch touched.
  2. Classify the change pattern: concentrated, scattered, or mirrored (parallel).
  3. If scattered, where should the "home" have been?
  4. If concentrated, what smaller classes would have kept change local?

Exercise 3: Premature abstraction sweep

Scan a codebase you know for interfaces with exactly one implementation. Do all of:

  1. List each one.
  2. For each, answer: is there a second real variant today or in the next sprint?
  3. Mark keep, inline, or decide later with a reason.
  4. Propose the inline refactor for any that have no justification.

Evidence Check

This page is complete only if you have:

  • a ranked smell list with concrete evidence quotes
  • a change-pattern classification for at least one real branch
  • at least one speculative-abstraction decision with a written justification