Naming Methods Automatically after Refactoring Operations
Creators: name: Abad, Juan Carlos Recio
Publisher: name: Zenodo
Year: 2023
Subjects: Method naming
Extract method refactoring
Natural language processing
Prompt
Method prediction

description: In Object-oriented Programming (OOP), the Cognitive Complexity (CC) of software is a metric of the difficulty associated with understanding and maintaining the source code. This is usually measured at the method level, taking into account the number of control flow sentences and their nesting level. One way to reduce the CC associated to a method is by extracting code into new methods without altering any existing functionality. However, this involves deciding on new names that are representative of the functionality of the extracted code.<br> This work focuses on large language models to automate the process of assigning new methods names after refactoring operations in software projects. We use the OpenAI Chat API with the text-davinci-003 model in orer to perform coding tasks. This work studies the capability of this technique for assigning names to new extracted methods during the evolution of a code base. Such evolution comprises continuous extraction operations to study how the method name semantics stability evolves. We found the precision of the model to be highly acceptable, achieving in many cases a level similar to that of a human. However, there are also a few cases in which it fails to provide appropriate names or does not even provide a name inside the indicated standards.
description: {"references": ["Uri Alon, Meital Zilberstein, Omer Levy, and Eran Yahav. code2vec: Learning distributed representations of code. 2018. https://doi.org/10.1145/3290353", "ri Alon, Shaked Brody, Omer Levy, and Eran Yahav. code2seq: Generating sequences from structured representations of code, 2019.", "G. Ann Campbell. Cognitive Complexity: An Overview and Evaluation. In Proceedings of the 2018 International Conference on Technical Debt, TechDebt '18, pages 57\u201358, New York, NY, USA, 2018. Association for Computing Machinery. https://doi.org/10.1145/3194164.3194186", "Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Pond \u0301e de Oliveira Pinto, Jared Kaplan, Harrison Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, Alex Ray, Raul Puri, Gretchen Krueger, Michael Petrov, Heidy Khlaaf, Girish Sastry, Pamela Mishkin, Brooke Chan, Scott Gray, Nick Ryder, Mikhail Pavlov, Alethea Power, Lukasz Kaiser, Mo- hammad Bavarian, Clemens Winter, Philippe Tillet, Felipe Petroski Such, Dave Cummings, Matthias Plappert, Fotios Chantzis, Elizabeth Barnes, Ariel Herbert-Voss, William Hebgen Guss, Alex Nichol, Alex Paino, Niko- las Tezak, Jie Tang, Igor Babuschkin, Suchir Balaji, Shantanu Jain, William Saunders, Christopher Hesse, Andrew N. Carr, Jan Leike, Joshua Achiam, Vedant Misra, Evan Morikawa, Alec Radford, Matthew Knight, Miles Brundage, Mira Murati, Katie Mayer, Peter Welinder, Bob McGrew, Dario Amodei, Sam McCandlish, Ilya Sutskever, and Wojciech Zaremba. Evalu- ating large language models trained on code. CoRR, abs/2107.03374, 2021. https://doi.org/10.5281/zenodo.4956884", "Shaiful Alam Chowdhury, Gias Uddin, and Reid Holmes. An empirical study on maintainable method size in java. 2022.", "Dror G. Feitelson, Ayelet Mizrahi, Nofar Noy, Aviad Ben Sha- bat, Or Eliyahu, and Roy Sheffer. How developers choose names. IEEE Transactions on Software Engineering, 48(1):37\u201352, jan 2022. https://doi.org/10.1109/tse.2020.2976920.", "Alex Graves. Generating sequences with recurrent neural networks. 2014", "Matthew Honnibal and Ines Montani. spaCy 2: Natural lan- guage understanding with Bloom embeddings, convolutional neural net- works and incremental parsing. 2017. URL https://sentometrics- research.com/publication/72/", "Thorsten Joachims. Text categorization with support vec- tor machines: Learning with many relevant features. 1998. https://doi.org/10.1007/BFb0026683"]}