volume_mute
Use Case - Refactoring Trigger
publish date: 2026/06/24 21:38:16.991051 UTC
volume_mute
While adding a new feature, a developer notices the same dozen lines of validation logic copy-pasted in five different files across the codebase. Following standard refactoring guidance, what would be the most appropriate action?
Correct Answer
Extract the duplicated logic into a single shared method and have all five locations call it
Explanation
This is the classic 'duplicate code' bad smell. The recommended refactoring response is to apply an extract method transformation, consolidating the duplicated logic into a single reusable method and having all the original locations call it. This reduces future maintenance burden, since a fix or update only needs to be made in one place.
Reference
Software Engineering, Ian Sommerville, 10th edition
