Method name prediction; naming convention; Automated tool support; Development tasks; Empirical analysis; Large-scales; Method implementations; Naming convention; Objectoriented programming (OOP); Real world projects; Research efforts; Software
Abstract :
[en] Method naming is a challenging development task in object-oriented programming. In recent years, several research efforts have been undertaken to provide automated tool support for assisting developers in this task. In general, literature approaches assume the availability of method implementation to infer its name. Methods, however, are usually named before their implementations. In this work, we fill the gap in the literature about method name prediction by developing an approach that predicts the names of all methods to be implemented within a class. Our work considers the class name as the input: The overall intuition is that classes with semantically similar names tend to provide similar functionalities, and hence similar method names. We first conduct a large-scale empirical analysis on 258K+ classes from real-world projects to validate our hypotheses. Then, we propose a hybrid big code-driven approach, Mario, to predict method names based on the class name: We combine a deep learning model with heuristics summarized from code analysis. Extensive experiments on 22K+ classes yielded promising results: compared to the state-of-the-art code2seq model (which leverages method implementation data), our approach achieves comparable results in terms of F-score at token-level prediction; our approach, additionally, outperforms code2seq in prediction at the name level. We further show that our approach significantly outperforms several other baselines.
Research center :
Interdisciplinary Centre for Security, Reliability and Trust (SnT) > TruX - Trustworthy Software Engineering
Disciplines :
Computer science
Author, co-author :
Wang, Shangwen ; Key Laboratory of Software Engineering for Complex Systems, College of Computer Science, National University of Defense Technology, Changsha, China
Wen, Ming ; School of Cyber Science and Engineering, Huazhong University of Science and Technology, Wuhan, China
Lin, Bo ; Key Laboratory of Software Engineering for Complex Systems, College of Computer Science, National University of Defense Technology, Changsha, China
Liu, Yepang ; Research Institute of Trustworthy Autonoumous Systems and Department of Computer Science and Engineering, Southern University of Science and Technology, Shenzhen, China
Mao, Xiaoguang ; Key Laboratory of Software Engineering for Complex Systems, College of Computer Science, National University of Defense Technology, Changsha, China
External co-authors :
yes
Language :
English
Title :
Pre-implementation Method Name Prediction for Object-oriented Programming
Publication date :
29 September 2023
Journal title :
ACM Transactions on Software Engineering and Methodology
This work was supported by the National Natural Science Foundation of China, Nos. 62002125 and 61932021, the Young Elite Scientists Sponsorship Program by CAST (Grant No. 2021QNRC001), and the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (grant agreement No. 949014).
Jordan Brown. 2022. 15 Java Coding Best Practices. Retrieved from https://xperti.io/blogs/java-coding-best-practices/.
Eclipse Foundation. 2022. Eclipse Foundation. Retrieved from https://www.eclipse.org/.
Martin O’Connor. 2022. Java Tutorial - How To Write A Method. Retrieved from https://www.youtube.com/watch?v=qQDGYfQPpGg.
NLTK. 2022. Stanford CoreNLP. Retrieved from https://github.com/nltk/nltk/wiki/Stanford-CoreNLP-API-in-NLTK.
Margaret Reid-Miller. 2022. Writing New Java Classes. Retrieved from https://www.cs.cmu.edu/~mrmiller/15-110/Handouts/writingClasses.pdf.
Surafel Lemma Abebe, Sonia Haiduc, Paolo Tonella, and Andrian Marcus. 2009. Lexicon bad smells in software. In Proceedings of the 16th Working Conference on Reverse Engineering. IEEE, 95–99.
Surafel Lemma Abebe and Paolo Tonella. 2010. Natural language parsing of program element names for concept extraction. In Proceedings of the IEEE 18th International Conference on Program Comprehension. IEEE, 156–159.
Surafel Lemma Abebe and Paolo Tonella. 2011. Towards the extraction of domain concepts from the identifiers. In Proceedings of the 18th Working Conference on Reverse Engineering. IEEE, 77–86.
Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray, and Kai-Wei Chang. 2020. A transformer-based approach for source code summarization. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics (ACL).
Jehad Al Dallal. 2010. Measuring the discriminative power of object-oriented class cohesion metrics. IEEE Trans. Softw. Eng. 37, 6 (2010), 788–804.
Jehad Al Dallal. 2013. Object-oriented class maintainability prediction using internal quality attributes. Inf. Softw. Technol. 55, 11 (2013), 2028–2048.
Miltiadis Allamanis, Earl T. Barr, Christian Bird, and Charles Sutton. 2015. Suggesting accurate method and class names. In Proceedings of the 10th Joint Meeting on Foundations of Software Engineering. ACM, 38–49. DOI:https://doi. org/10.1145/2786805.2786849
Miltiadis Allamanis, Earl T. Barr, Christian Bird, and Charles A. Sutton. 2014. Learning natural coding conventions. In Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering. ACM, 281–293. DOI:https://doi.org/10.1145/2635868.2635883
Miltiadis Allamanis, Earl T. Barr, Premkumar T. Devanbu, and Charles A. Sutton. 2018. A survey of machine learning for big code and naturalness. Comput. Surv. 51, 4 (2018), 81:1–81:37. DOI:https://doi.org/10.1145/3212695
Miltiadis Allamanis, Marc Brockschmidt, and Mahmoud Khademi. 2018. Learning to represent programs with graphs. In Proceedings of the 6th International Conference on Learning Representations. OpenReview.net.
Miltiadis Allamanis, Hao Peng, and Charles Sutton. 2016. A convolutional attention network for extreme summarization of source code. In Proceedings of the 33rd International Conference on Machine Learning. JMLR.org, 2091–2100.
Uri Alon, Shaked Brody, Omer Levy, and Eran Yahav. 2019. code2seq: Generating sequences from structured representations of code. In Proceedings of the 7th International Conference on Learning Representations. OpenReview.net.
Uri Alon, Meital Zilberstein, Omer Levy, and Eran Yahav. 2019. code2vec: Learning distributed representations of code. Proceed. ACM Program. Lang. 3, POPL (2019), 40:1–40:29. DOI:https://doi.org/10.1145/3290353
Reem S. Alsuhaibani, Christian D. Newman, M. J. Decker, Michael L. Collard, and J. Maletic. 2021. On the naming of methods: A survey of professional developers. In Proceedings of the IEEE/ACM 43rd International Conference on Software Engineering (ICSE). 587–599.
Venera Arnaoudova, Massimiliano Di Penta, and Giuliano Antoniol. 2016. Linguistic antipatterns: What they are and how developers perceive them. Empir. Softw. Eng. 21, 1 (2016), 104–158.
Venera Arnaoudova, Massimiliano Di Penta, Giuliano Antoniol, and Yann-Gaël Guéhéneuc. 2013. A new family of software anti-patterns: Linguistic anti-patterns. In Proceedings of the 17th European Conference on Software Maintenance and Reengineering, 187–196.
Dave Binkley, Marcia Davis, Dawn Lawrie, Jonathan I. Maletic, Christopher Morrell, and Bonita Sharif. 2013. The impact of identifier style on effort and comprehension. Empir. Softw. Eng. 18, 2 (2013), 219–276.
Dave Binkley, Marcia Davis, Dawn Lawrie, and Christopher Morrell. 2009. To camelcase or under_score. In Proceedings of the IEEE 17th International Conference on Program Comprehension. IEEE, 158–167.
Dave Binkley, Matthew Hearn, and Dawn Lawrie. 2011. Improving identifier informativeness using part of speech information. In Proceedings of the 8th Working Conference on Mining Software Repositories. 203–206.
Marcel Bruch, Martin Monperrus, and Mira Mezini. 2009. Learning from examples to improve code completion systems. In Proceedings of the 7th Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on the Foundations of Software Engineering. 213–222.
Nghi D. Q. Bui, Yijun Yu, and Lingxiao Jiang. 2021. TreeCaps: Tree-based capsule networks for source code processing. In Proceedings of the 35th AAAI Conference on Artificial Intelligence.
Simon Butler, Michel Wermelinger, and Yijun Yu. 2015. Investigating naming convention adherence in Java references. In Proceedings of the IEEE International Conference on Software Maintenance and Evolution (ICSME). IEEE, 41–50.
Simon Butler, Michel Wermelinger, and Yijun Yu. 2015. A survey of the forms of Java reference names. In Proceedings of the IEEE 23rd International Conference on Program Comprehension. IEEE, 196–206.
Simon Butler, Michel Wermelinger, Yijun Yu, and Helen Sharp. 2011. Mining Java class naming conventions. In Proceedings of the 27th IEEE International Conference on Software Maintenance (ICSM). 93–102. DOI:https://doi.org/10. 1109/ICSM.2011.6080776
C. Caprile and Paolo Tonella. 1999. Nomen est omen: Analyzing the language of function identifiers. In Proceedings of the 6th Working Conference on Reverse Engineering. IEEE, 112–122.
Norman Cliff. 1996. Ordinal methods for behavioral data analysis. https://www.taylorfrancis.com/books/mono/10.4324/9781315806730/ordinal-methods-behavioral-data-analysis-norman-cliff.
Anna Corazza, Sergio Di Martino, and Valerio Maggio. 2012. LINSEN: An efficient approach to split identifiers and expand abbreviations. In Proceedings of the 28th IEEE International Conference on Software Maintenance (ICSM). IEEE, 233–242.
Florian Deissenboeck and Markus Pizka. 2006. Concise and consistent naming. Softw. Qual. J. 14, 3 (2006), 261–282.
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies. 4171–4186. DOI:https://doi.org/10.18653/v1/n19-1423
Eric Enslen, Emily Hill, Lori Pollock, and K. Vijay-Shanker. 2009. Mining source code to automatically split identifiers for software analysis. In Proceedings of the 6th IEEE International Working Conference on Mining Software Repositories. IEEE, 71–80.
Yuanrui Fan, Xin Xia, Daniel Alencar Da Costa, David Lo, Ahmed E. Hassan, and Shanping Li. 2019. The impact of mislabeled changes by SZZ on just-in-time defect prediction. IEEE Trans. Softw. Eng. 47, 8 (2019), 1559–1586.
Zachary P. Fry, David Shepherd, Emily Hill, Lori Pollock, and K. Vijay-Shanker. 2008. Analysing source code: Looking for useful verb–direct object pairs in all the right places. IET Softw. 2, 1 (2008), 27–36.
Mingyang Geng, Shangwen Wang, Dezun Dong, Haotian Wang, Shaomeng Cao, Kechi Zhang, and Zhi Jin. 2023. Interpretation-based code summarization. In Proceedings of the IEEE/ACM 31st International Conference on Program Comprehension (ICPC).
Malcom Gethers, Trevor Savage, Massimiliano Di Penta, Rocco Oliveto, Denys Poshyvanyk, and Andrea De Lucia. 2011. CodeTopics: Which topic am I coding now? In Proceedings of the 33rd International Conference on Software Engineering. 1034–1036.
Joseph Gil and Itay Maman. 2005. Micro patterns in Java code. In Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications. 97–116.
Edouard Grave, Piotr Bojanowski, Prakhar Gupta, Armand Joulin, and Tomas Mikolov. 2018. Learning word vectors for 157 languages. arXiv preprint arXiv:1802.06893 (2018).
Samir Gupta, Sana Malik, Lori Pollock, and K. Vijay-Shanker. 2013. Part-of-speech tagging of program identifiers for improved text-based software engineering tools. In Proceedings of the 21st International Conference on Program Comprehension (ICPC). IEEE, 3–12.
Udo Hahn and Inderjeet Mani. 2000. The challenges of automatic summarization. Computer 33, 11 (2000), 29–36.
Sonia Haiduc, Jairo Aponte, Laura Moreno, and Andrian Marcus. 2010. On the use of automated text summarization techniques for summarizing source code. In Proceedings of the 17th Working Conference on Reverse Engineering. IEEE, 35–44.
Jingxuan He, Cheng-Chun Lee, Veselin Raychev, and Martin Vechev. 2021. Learning to find naming issues with big code and small supervision. In Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation. 296–311. DOI:https://doi.org/10.1145/3453483.3454045
Vincent J. Hellendoorn and Premkumar Devanbu. 2017. Are deep neural networks the best choice for modeling source code? In Proceedings of the 11th Joint Meeting on Foundations of Software Engineering. 763–773.
Vincent J. Hellendoorn, Charles Sutton, Rishabh Singh, Petros Maniatis, and David Bieber. 2020. Global relational models of source code. In Proceedings of the 8th International Conference on Learning Representations (ICLR). OpenReview.net.
Yoshiki Higo and Shinji Kusumoto. 2012. How often do unintended inconsistencies happen? Deriving modification patterns and detecting overlooked code fragments. In Proceedings of the 28th IEEE International Conference on Software Maintenance (ICSM). IEEE, 222–231.
Emily Hill, David Binkley, Dawn Lawrie, Lori Pollock, and K. Vijay-Shanker. 2014. An empirical study of identifier splitting techniques. Empir. Softw. Eng. 19, 6 (2014), 1754–1780.
Emily Hill, Lori Pollock, and K. Vijay-Shanker. 2011. Improving source code search with natural language phrasal representations of method signatures. In Proceedings of the 26th IEEE/ACM International Conference on Automated Software Engineering (ASE’11). IEEE, 524–527.
Abram Hindle, Earl T. Barr, Zhendong Su, Mark Gabel, and Premkumar T. Devanbu. 2012. On the naturalness of software. In Proceedings of the 34th International Conference on Software Engineering. IEEE, 837–847. DOI:https://doi. org/10.1109/ICSE.2012.6227135
Einar W. Høst and Bjarte M. Østvold. 2009. Debugging method names. In Proceedings of the 23rd European Conference on Object-Oriented Programming (ECOOP). 294–317.
Lin Jiang, Hui Liu, and He Jiang. 2019. Machine learning based recommendation of method names: How far are we. In Proceedings of the 34th IEEE/ACM International Conference on Automated Software Engineering (ASE). 602–614. DOI:https://doi.org/10.1109/ASE.2019.00062
Rafael-Michael Karampatsis, Hlib Babii, Romain Robbes, Charles Sutton, and Andrea Janes. 2020. Big code!= big vocabulary: Open-vocabulary models for source code. In Proceedings of the IEEE/ACM 42nd International Conference on Software Engineering (ICSE). IEEE, 1073–1085.
Suntae Kim and Dongsun Kim. 2016. Automatic identifier inconsistency detection using code dictionary. Empir. Softw. Eng. 21, 2 (2016), 565–604.
Seohyun Kim, Jinman Zhao, Yuchi Tian, and Satish Chandra. 2021. Code prediction by feeding trees to transformers. In Proceedings of the IEEE/ACM 43rd International Conference on Software Engineering (ICSE). IEEE, 150–162.
Pavneet Singh Kochhar, Eirini Kalliamvakou, Nachiappan Nagappan, Thomas Zimmermann, and Christian Bird. 2019. Moving from closed to open source: Observations from six transitioned projects to github. IEEE Transactions on Software Engineering 47, 9 (2019), 1838–1856.
Yi Li, Shaohua Wang, and Tien N. Nguyen. 2021. A context-based automated approach for method name consistency checking and suggestion. In Proceedings of the 43rd International Conference on Software Engineering.
Bo Lin, Shangwen Wang, Kui Liu, Xiaoguang Mao, and Tegawendé F. Bissyandé. 2021. Automated comment update: How far are we? In Proceedings of the 29th IEEE/ACM International Conference on Program Comprehension (ICPC). 36–46.
Bo Lin, Shangwen Wang, Zhongxin Liu, Xin Xia, and Xiaoguang Mao. 2023. Predictive comment updating with heuristics and AST-path-based neural learning: A two-phase approach. IEEE Transactions on Software Engineering 49, 4 (2023), 1640–1660. DOI:10.1109/TSE.2022.3185458
Bo Lin, Shangwen Wang, Ming Wen, and Xiaoguang Mao. 2022. Context-aware code change embedding for better patch correctness assessment. ACM Trans. Softw. Eng. Methodol. 31, 3 (May 2022). DOI:https://doi.org/10.1145/3505247
Fang Liu, Ge Li, Yunfei Zhao, and Zhi Jin. 2020. Multi-task learning based pre-trained language model for code completion. In Proceedings of the 35th IEEE/ACM International Conference on Automated Software Engineering. 473–485.
Fang Liu, Lu Zhang, and Zhi Jin. 2020. Modeling programs hierarchically with stack-augmented LSTM. J. Syst. Softw. 164 (2020), 110547.
Kui Liu, Dongsun Kim, Tegawendé F. Bissyandé, Tae-young Kim, Kisub Kim, Anil Koyuncu, Suntae Kim, and Yves Le Traon. 2019. Learning to spot and refactor inconsistent method names. In Proceedings of the 41st International Conference on Software Engineering. IEEE, 1–12. DOI:https://doi.org/10.1109/ICSE.2019.00019
Cristina V. Lopes, Petr Maj, Pedro Martins, Vaibhav Saini, Di Yang, Jakub Zitny, Hitesh Sajnani, and Jan Vitek. 2017. DéjàVu: A map of code duplicates on GitHub. Proc. ACM Program. Lang. 1, OOPSLA (2017), 1–28.
Henry B. Mann and Donald R. Whitney. 1947. On a test of whether one of two random variables is stochastically larger than the other. Annals Math. Statist. 18, 1 (1947), 50–60. DOI:https://doi.org/10.1214/aoms/1177730491
Laura Moreno, Jairo Aponte, Giriprasad Sridhara, Andrian Marcus, Lori Pollock, and K. Vijay-Shanker. 2013. Automatic generation of natural language summaries for Java classes. In Proceedings of the 21st International Conference on Program Comprehension (ICPC). IEEE, 23–32.
Lili Mou, Ge Li, Lu Zhang, Tao Wang, and Zhi Jin. 2016. Convolutional neural networks over tree structures for programming language processing. In Proceedings of the AAAI Conference on Artificial Intelligence.
Son Nguyen, Hung Phan, Trinh Le, and Tien N. Nguyen. 2020. Suggesting natural method names to check name consistencies. In Proceedings of the ACM/IEEE 42nd International Conference on Software Engineering. 1372–1384.
Hector M. Olague, Letha H. Etzkorn, Sherri L. Messimer, and Harry S. Delugach. 2008. An empirical validation of object-oriented class complexity metrics and their ability to predict error-prone classes in highly iterative, or agile, software: A case study. J. Softw. Maint. Evolut.: Res. Pract. 20, 3 (2008), 171–197.
Wyatt Olney, Emily Hill, Chris Thurber, and Bezalem Lemma. 2016. Part of speech tagging Java method names. In Proceedings of the IEEE International Conference on Software Maintenance and Evolution (ICSME). IEEE, 483–487.
Luca Ponzanelli, Simone Scalabrino, Gabriele Bavota, Andrea Mocci, Rocco Oliveto, Massimiliano Di Penta, and Michele Lanza. 2017. Supporting software developers with a holistic recommender system. In Proceedings of the IEEE/ACM 39th International Conference on Software Engineering (ICSE). IEEE, 94–105.
Václav Rajlich and Norman Wilde. 2002. The role of concepts in program comprehension. In Proceedings of the 10th International Workshop on Program Comprehension. IEEE, 271–278.
Peter C. Rigby and Martin P. Robillard. 2013. Discovering essential code elements in informal documentation. In Proceedings of the 35th International Conference on Software Engineering (ICSE). IEEE, 832–841.
Romain Robbes and Michele Lanza. 2007. Characterizing and understanding development sessions. In Proceedings of the 15th IEEE International Conference on Program Comprehension (ICPC’07). IEEE, 155–166.
Romain Robbes and Michele Lanza. 2010. Improving code completion with program history. Autom. Softw. Eng. 17, 2 (2010), 181–212.
Hitesh Sajnani, Vaibhav Saini, Jeffrey Svajlenko, Chanchal K. Roy, and Cristina V. Lopes. 2016. SourcererCC: Scaling code clone detection to big-code. In Proceedings of the 38th International Conference on Software Engineering. 1157–1168.
C. S. Saranyamol and L. Sindhu. 2014. A survey on automatic text summarization. Int. J. Comput. Sci. Inf. Technol. 5, 6 (2014), 7889–7893.
Jeremy Singer and Chris Kirkham. 2008. Exploiting the correspondence between micro patterns and class names. In Proceedings of the 8th IEEE International Working Conference on Source Code Analysis and Manipulation. IEEE, 67–76.
Christoph Treude and Martin P. Robillard. 2016. Augmenting API documentation with insights from stack overflow. In Proceedings of the IEEE/ACM 38th International Conference on Software Engineering (ICSE). IEEE, 392–403.
Zhaopeng Tu, Zhendong Su, and Premkumar Devanbu. 2014. On the localness of software. In Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering. 269–280.
Michele Tufano, Jevgenija Pantiuchina, Cody Watson, Gabriele Bavota, and Denys Poshyvanyk. 2019. On learning meaningful code changes via neural machine translation. In Proceedings of the IEEE/ACM 41st International Conference on Software Engineering (ICSE). IEEE, 25–36.
Michele Tufano, Cody Watson, Gabriele Bavota, Massimiliano Di Penta, Martin White, and Denys Poshyvanyk. 2019. An empirical study on learning bug-fixing patches in the wild via neural machine translation. ACM Trans. Softw. Eng. Methodol. 28, 4 (2019), 19:1–19:29. DOI:https://doi.org/10.1145/3340544
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. In Proceedings of the Conference on Advances in Neural Information Processing Systems. 6000–6010.
Shangwen Wang, Kui Liu, Bo Lin, Li Li, Jacques Klein, Xiaoguang Mao, and Tegawendé F. Bissyandé. 2021. Beep: Fine-grained fix localization by learning to predict buggy code elements. arXiv preprint arXiv:2111.07739 (2021).
Shangwen Wang, Ming Wen, Bo Lin, and Xiaoguang Mao. 2021. Lightweight global and local contexts guided method name recommendation with prior knowledge. In Proceedings of the 29th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE).
Fengcai Wen, Emad Aghajani, Csaba Nagy, Michele Lanza, and Gabriele Bavota. 2021. Siri, write the next method. In Proceedings of the IEEE/ACM 43rd International Conference on Software Engineering (ICSE). IEEE, 138–149.
Martin White, Michele Tufano, Christopher Vendome, and Denys Poshyvanyk. 2016. Deep learning code fragments for code clone detection. In Proceedings of the 31st IEEE/ACM International Conference on Automated Software Engineering (ASE). IEEE, 87–98.
F. Wilcoxon. 1945. Individual comparisons by ranking methods. Biomet. Bull. 1, 6 (1945), 80–83.
Jianwei Wu and James Clause. 2020. A pattern-based approach to detect and improve non-descriptive test names. Journal of Systems and Software 168 (2020), 110639. DOI:https://doi.org/10.1016/j.jss.2020.110639
Yuming Zhou, Baowen Xu, and Hareton Leung. 2010. On the ability of complexity metrics to predict fault-prone classes in object-oriented systems. J. Syst. Softw. 83, 4 (2010), 660–674.