language-icon Old Web
English
Sign In

Shotgun surgery

Shotgun surgery is an antipattern in software development and occurs where a developer adds features to an application codebase which span a multiplicity of implementors or implementations in a single change. This is common practice in many programming scenarios, as a great amount of programming effort is usually expended on adding new features to increase the value of programming assets. As a consequence, these new features may require adding code in several places simultaneously where the code itself looks very similar and may only have slight variations. Owing to the fast-paced nature of commercial software development, there may not be sufficient time to remodel (or refactor) a system to support the new features trivially. As a consequence, the practice of cut and paste coding is prevalent; the code is written in a single place then simply copied to all other places where that implementation is required (with any required changes applied in-place). This practice is generally frowned on by the refactoring community as a direct violation of the Once and Only Once principle – ultimately any change to the new functionality may require widespread changes. Further, any potential software bug in this new feature will be replicated many-fold and can make bug fixing particularly difficult and tedious. Even in the absence of copied code, the implementations are guaranteed to be very similar and just as prone to requirements change or bug fixing. This form of software development tends to favour short-term improvement (in the form of additional features) at the cost of long-term maintainability and stability. Shotgun surgery is an antipattern in software development and occurs where a developer adds features to an application codebase which span a multiplicity of implementors or implementations in a single change. This is common practice in many programming scenarios, as a great amount of programming effort is usually expended on adding new features to increase the value of programming assets. As a consequence, these new features may require adding code in several places simultaneously where the code itself looks very similar and may only have slight variations. Owing to the fast-paced nature of commercial software development, there may not be sufficient time to remodel (or refactor) a system to support the new features trivially. As a consequence, the practice of cut and paste coding is prevalent; the code is written in a single place then simply copied to all other places where that implementation is required (with any required changes applied in-place). This practice is generally frowned on by the refactoring community as a direct violation of the Once and Only Once principle – ultimately any change to the new functionality may require widespread changes. Further, any potential software bug in this new feature will be replicated many-fold and can make bug fixing particularly difficult and tedious. Even in the absence of copied code, the implementations are guaranteed to be very similar and just as prone to requirements change or bug fixing. This form of software development tends to favour short-term improvement (in the form of additional features) at the cost of long-term maintainability and stability. The canonical example of this practice is logging which generally adds prologue code to many functions simultaneously, for example:

[ "Object (computer science)", "Software quality", "Software construction", "Software maintenance", "God object" ]
Parent Topic
Child Topic
    No Parent Topic