CS FundamentalsVery hardProduct-company design interview

A change to how GST is calculated forces small edits in nine different classes across the code base. Which code smell is this, and how does it differ from 'divergent change'?

  1. A. Divergent change; it is the same as shotgun surgery
  2. B. Feature envy; the GST code envies other classes
  3. C. Shotgun surgery: one kind of change touches many classes, whereas divergent change is one class changing for many unrelated reasons
  4. D. Long method; split the methods

Correct answer: C. Shotgun surgery: one kind of change touches many classes, whereas divergent change is one class changing for many unrelated reasons

Shotgun surgery scatters a single responsibility (fix: move it into one place); divergent change crams many responsibilities into one class (fix: split it). They are opposite symptoms of poor responsibility assignment.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic