Tests as Specifications Towards Better Code Completion
Diogo Miguel Rebelo Borges Amado de Campos · Open Repository of the University of Porto (University of Porto) · 2019
Software development is inherently complex, both from a technical and a process standpoint.Over the years, progress has been made to simplify and accelerate it, with the advent of higher level programming languages and build systems on the technical side and software development processes focused on agility on the process side.Live Programming entails the notion of providing live feedback to developers, reducing the feedback loop of the edit-compile-run software development cycle and fastening the software development process.Existing code completion tools, commonly used by developers, provide them with syntactic suggestions as live feedback, but still lack the ability to provide semantic ones.Automated Program Repair is an area of research focused on automating the act of fixing bugs, one of the complex tasks in software development.While current solutions display promising results, they also present some limitations, namely in terms of maintainability of the code or in producing overfitted patches.Combining both these areas, we propose a live Automated Program Repair tool, here implemented as an extension to Visual Studio Code, which leverages unit tests as specifications and generates code variations to repair bugs in JavaScript code.With this, we provide real-time semantic suggestions to developers while they write code, achieving a level 5 in the liveness hierarchy, corresponding to tactically predictive feedback.Furthermore, by doing so, we believe that such an approach would allow developers to discard those suggestions they deem as overfitted or as reducing maintainability.The patches (candidate repairs to the faulty program) are generated by using a mutation-based Automated Program Repair technique, which enables us to generate candidate solutions in a timely manner and find fixes within the time constraints required to offer liveness as an attribute.An empirical study with 16 participants was conducted, with results showing that a live Automated Program Repair tool improves the speed of developers in repairing faulty programs.In addition, we establish that there is a difference in the final code of developers using the extension when compared with those not using it.The contributions of this work include the implemented Visual Studio Code extension as well as the aforementioned empirical study.i My sincere gratitude to my supervisors, André Restivo and Hugo Sereno Ferreira, for their guidance, knowledge, patience, and unwavering support and even more so for their continued enthusiasm and never-ending ideas.Many thanks to Filipe Correia and João Pedro Dias, who, in spite of not being my supervisors, were always around to answer any question, help solve any problem or discuss new ideas, as well as to Sara Fernandes and Mário Fernandes, who heard my weekly rants and with whom I had the most productive discussions while drinking vending machine coffee of questionable quality.To Carolina, who almost single-handedly kept me sane, whose love, support, patience and empathy are endless, who put up with all-nighters and mood swings, my profound gratitude.My heartfelt thanks to my family, for none of this would be possible without them.No words can describe the support they have given me.It is a debt I can never repay.I am forever grateful for two very special groups of