Copy and Paste Redeemed

Research output: Chapter in Book/Report/Conference proceedingPaper in conference proceeding

Abstract

Modern software development relies on code reuse, which software engineers typically realise through handwritten abstractions, such as functions, methods, or classes. However, such abstractions can be challenging to develop and maintain. One alternative form of re-use is copy-paste-modify, a methodology in which developers explicitly duplicate source code to adapt the duplicate for a new purpose. We observe that copy-paste-modify can be substantially faster to use than manual abstraction, and past research strongly suggests that it is a popular technique among software developers. We therefore propose that software engineers should forego hand-written abstractions in favour of copying and pasting. However, empirical evidence also shows that copy-paste-modify complicates software maintenance and increases the frequency of bugs. To address this concern, we propose a software tool that merges together similar pieces of code and automatically creates suitable abstractions. This allows software developers to get the best of both worlds: custom abstraction together with easy re-use. To demonstrate the feasibility of our approach, we have implemented and evaluated a prototype merging tool for C++ on a number of near-miss clones (clones with some modifications) in popular Open Source packages. We found that maintainers find our algorithmically created abstractions to be largely preferable to existing duplicated code.

Details

Authors
External organisations
  • Goethe University
Research areas and keywords

Subject classification (UKÄ) – MANDATORY

  • Software Engineering
Original languageEnglish
Title of host publication 30th IEEE/ACM International Conference on Automated Software Engineering (ASE), 2015
PublisherIEEE Computer Society
Pages630-640
ISBN (Electronic)978-1-5090-0025-8
Publication statusPublished - 2015 Nov 9
Publication categoryResearch
Peer-reviewedYes
Externally publishedYes

Bibliographic note

ASE Distinguished Paper Award

Related prizes

Christoph Reichenbach (Recipient), 2015 Nov 13

Prizes and Distinctions: Prize (including medals and awards)

View all (1)