WG211/M15Reichenbach
Copy and Paste Redeemed by Christoph Reichenbach
Software development and, especially, generative programming leverage abstractions as a means for re-using information. However, such abstractions can be challenging to develop and maintain. An alternative is to re-use existing source code by copy-paste-modify, a methodology in which source code is explicitly duplicated and one of the duplicates adapted for a new but similar purpose.
We have conducted a user study that suggest that software engineers find copy-paste-modify to be faster than manual abstraction for common re-use tasks. We therefore propose that software engineers should forego hand-written abstractions in favour of copying and pasting. To address the potential maintenance and comprehension challenges caused by massive code duplication, we propose a software tool that `folds together' similar pieces of code and automatically creates suitable abstrations. This allows software developers to get the best of both worlds: custom abstraction, together with easy re-use.
We have evaluated the tool with a number of abstraction tasks taken from popular Open Source projects and found it to be effective; moreover, project maintainers are generally willing to incorporate abstractions introduced by our tool into their revision control repositories.