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'?
- A. Divergent change; it is the same as shotgun surgery
- B. Feature envy; the GST code envies other classes
- C. Shotgun surgery: one kind of change touches many classes, whereas divergent change is one class changing for many unrelated reasons
- 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.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- Match each code smell with the refactoring that usually fixes it. P: a method takes 9 parameters, several of which always travel together…
- Using the Chidamber-Kemerer metric CBO (coupling between objects: the number of other classes a class is coupled to, counting both classes…
- Class Cart has 5 methods. Together they call 9 methods of other classes, of which 7 are distinct. What is its Response For a Class (RFC) =…
- A class has four methods with cyclomatic complexities 1, 3, 2 and 4. Using the CK metric Weighted Methods per Class (WMC) with cyclomatic…
- David Parnas's information-hiding principle says how a system should be divided into modules. Which statement captures it?
- Match each system with its architectural style. P: a compiler with lexer → parser → optimiser → code generator. Q: a typical 3-tier web…