ABSTRACT
Feature envy is one of the well-recognized code smells that should be removed by software refactoring. A major challenge in feature envy detection is that traditional approaches are less accurate whereas deep learning-based approaches are suffering from the lack of high-quality large-scale training data. Although existing refactoring detection tools could be employed to discover real-world feature envy examples, the noise (i.e., false positives) within the resulting data could significantly influence the quality of the training data as well as the performance of the models trained on the data. To this end, in this paper, we propose a sequence of heuristic rules and a decision tree-based classifier to filter out false positives reported by state-of-the-art refactoring detection tools. The data after filtering serve as the positive items in the requested training data. From the same subject projects, we randomly select methods that are different from positive items as negative items. With the real-world examples (both positive and negative examples), we design and train a deep learning-based binary model to predict whether a given method should be moved to a potential target class. Different from existing models, it leverages additional features, i.e., coupling between methods and classes (CBMC) and the message passing coupling between methods and classes (MCMC) that have not yet been exploited by existing approaches. Our evaluation results on real-world open-source projects suggest that the proposed approach substantially outperforms the state of the art in feature envy detection, improving precision and recall by 38.5% and 20.8%, respectively.
- Uri Alon, Meital Zilberstein, Omer Levy, and Eran Yahav. 2019. Code2vec: Learning Distributed Representations of Code. Proceedings of the ACM on Programming Languages, 3, POPL (2019), 40:1–40:29. https://doi.org/10.1145/3290353 Google ScholarDigital Library
- Lucas Amorim, Evandro Costa, Nuno Antunes, Baldoino Fonseca, and Márcio Ribeiro. 2015. Experience Report: Evaluating the Effectiveness of Decision Trees for Detecting Code Smells. In Proceedings of the 26th IEEE International Symposium on Software Reliability Engineering (ISSRE ’15). IEEE, Gaithersbury, MD, USA. 261–269. https://doi.org/10.1109/ISSRE.2015.7381819 Google ScholarDigital Library
- Muhammad Ilyas Azeem, Fabio Palomba, Lin Shi, and Qing Wang. 2019. Machine Learning Techniques for Code Smell Detection: A Systematic Literature Review and Meta-Analysis. Information and Software Technology, 108 (2019), 115–138. https://doi.org/10.1016/j.infsof.2018.12.009 Google ScholarCross Ref
- Antoine Barbez, Foutse Khomh, and Yann-Gaël Guéhéneuc. 2020. A Machine-Learning Based Ensemble Method for Anti-Patterns Detection. Journal of Systems and Software, 161 (2020), 110486. https://doi.org/10.1016/j.jss.2019.110486 Google ScholarDigital Library
- Gabriele Bavota, Rocco Oliveto, Malcom Gethers, Denys Poshyvanyk, and Andrea De Lucia. 2014. Methodbook: Recommending Move Method Refactorings via Relational Topic Models. IEEE Transactions on Software Engineering, 40, 7 (2014), 671–694. https://doi.org/10.1109/TSE.2013.60 Google ScholarDigital Library
- Leo Breiman. 1984. Classification and Regression Trees. Wadsworth, Belmont, CA, USA. Google Scholar
- Andrei Z Broder. 1997. On the Resemblance and Containment of Documents. In Proceedings of Compression and Complexity of SEQUENCES (SEQUENCES ’97). IEEE, Salerno, Italy. 21–29. https://doi.org/10.1109/SEQUEN.1997.666900 Google ScholarCross Ref
- Flavio Chierichetti, Ravi Kumar, Sandeep Pandey, and Sergei Vassilvitskii. 2010. Finding the Jaccard Median. In Proceedings of the 21st Annual ACM-SIAM Symposium on Discrete Algorithms (SODA ’10). SIAM, Austin, TX, USA. 293–311. https://doi.org/10.1137/1.9781611973075.25 Google ScholarCross Ref
- Di Cui, Siqi Wang, Yong Luo, Xingyu Li, Jie Dai, Lu Wang, and Qingshan Li. 2022. RMove: Recommending Move Method Refactoring Opportunities using Structural and Semantic Representations of Code. In Proceedings of the 38th IEEE International Conference on Software Maintenance and Evolution (ICSME ’22). IEEE, Limassol, Cyprus. 281–292. https://doi.org/10.1109/ICSME55016.2022.00033 Google ScholarCross Ref
- Marco D’Ambros, Alberto Bacchelli, and Michele Lanza. 2010. On the Impact of Design Flaws on Software Defects. In Proceedings of the 10th International Conference on Quality Software (QSIC ’10). IEEE, Zhangjiajie, China. 23–31. https://doi.org/10.1109/QSIC.2010.58 Google ScholarDigital Library
- Kris De Volder. 1998. Type-Oriented Logic Meta Programming. Ph. D. Dissertation. Vrije Universiteit Brussel, Programming Technology Laboratory. Google Scholar
- Chris Dennis. 2023. Quartz. https://github.com/quartz-scheduler/quartz/blob/ff348f62ece41275555b45dba5a4073c910fbeab/quartz-core/src/main/java/org/quartz/impl/StdSchedulerFactory.java/#L1404 Google Scholar
- Dario Di Nucci, Fabio Palomba, Damian A Tamburri, Alexander Serebrenik, and Andrea De Lucia. 2018. Detecting Code Smells Using Machine Learning Techniques: Are We There Yet? In Proceedings of the 25th International Conference on Software Analysis, Evolution and Reengineering (SANER ’18). IEEE, Campobasso, Italy. 612–621. https://doi.org/10.1109/SANER.2018.8330266 Google ScholarCross Ref
- Danny Dig, Can Comertoglu, Darko Marinov, and Ralph Johnson. 2006. Automated Detection of Refactorings in Evolving Components. In Proceedings of the 20th European Conference on Object-Oriented Programming (ECOOP ’06). Springer, Nantes, France. 404–428. https://doi.org/10.1007/11785477_24 Google ScholarDigital Library
- Eduardo Fernandes, Johnatan Oliveira, Gustavo Vale, Thanis Paiva, and Eduardo Figueiredo. 2016. A Review-Based Comparative Study of Bad Smell Detection Tools. In Proceedings of the 20th International Conference on Evaluation and Assessment in Software Engineering (EASE ’16). ACM, Limerick, Ireland. 1–12. https://doi.org/10.1145/2915970.2915984 Google ScholarDigital Library
- Joseph L Fleiss. 1971. Measuring Nominal Scale Agreement Among Many Raters. Psychological Bulletin, 76, 5 (1971), 378–382. https://doi.org/10.1037/h0031619 Google ScholarCross Ref
- Marios Fokaefs, Nikolaos Tsantalis, and Alexander Chatzigeorgiou. 2007. JDeodorant: Identification and Removal of Feature Envy Bad Smells. In Proceedings of the 23rd IEEE International Conference on Software Maintenance (ICSM ’07). IEEE, Paris, France. 519–520. https://doi.org/10.1109/ICSM.2007.4362679 Google ScholarCross Ref
- Francesca Arcelli Fontana, Pietro Braione, and Marco Zanoni. 2012. Automatic Detection of Bad Smells in Code: An Experimental Assessment. Journal of Object Technology, 11, 2 (2012), 5:1–38. https://doi.org/10.5381/jot.2012.11.2.a5 Google ScholarCross Ref
- Francesca Arcelli Fontana, Mika V Mäntylä, Marco Zanoni, and Alessandro Marino. 2016. Comparing and Experimenting Machine Learning Techniques for Code Smell Detection. Empirical Software Engineering, 21, 3 (2016), 1143–1191. https://doi.org/10.1007/s10664-015-9378-4 Google ScholarDigital Library
- Francesca Arcelli Fontana, Elia Mariani, Andrea Mornioli, Raul Sormani, and Alberto Tonello. 2011. An Experience Report on Using Code Smells Detection Tools. In Proceedings of the 4th IEEE International Conference on Software Testing, Verification and Validation Workshop on Refactoring and Testing Analysis (ICSTW ’11). IEEE, Berlin, Germany. 450–457. https://doi.org/10.1109/ICSTW.2011.12 Google ScholarDigital Library
- Francesca Arcelli Fontana and Marco Zanoni. 2017. Code Smell Severity Classification Using Machine Learning Techniques. Knowledge Based Systems, 128 (2017), 43–58. https://doi.org/10.1016/j.knosys.2017.04.014 Google ScholarDigital Library
- Francesca Arcelli Fontana, Marco Zanoni, Alessandro Marino, and Mika Mäntylä. 2013. Code Smell Detection: Towards a Machine Learning-Based Approach. In Proceedings of the 2013 IEEE International Conference on Software Maintenance (ICSM ’13). IEEE, Eindhoven, Netherlands. 396–399. https://doi.org/10.1109/ICSM.2013.56 Google ScholarDigital Library
- Martin Fowler. 1999. Refactoring: Improving the Design of Existing Code. Addison-Wesley, Boston, MA, USA. Google ScholarDigital Library
- Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. 1995. Design Patterns: Elements of Reusable Object-Oriented Software. Pearson Deutschland GmbH, Munich, Germany. Google Scholar
- Adnane Ghannem, Ghizlane El Boussaidi, and Marouane Kessentini. 2016. On the Use of Design Defect Examples to Detect Model Refactoring Opportunities. Software Quality Journal, 24, 4 (2016), 947–965. https://doi.org/10.1007/s11219-015-9271-9 Google ScholarDigital Library
- Gary Gregory. 2023. Commons-CSV. https://github.com/apache/commons-csv/blob/db374369aeeb1f3ace8efcbd7155fcff20354504/src/main/java/org/apache/commons/csv/Lexer.java#L128 Google Scholar
- Mouna Hadj-Kacem and Nadia Bouassida. 2019. Deep Representation Learning for Code Smells Detection using Variational Auto-Encoder. In Proceedings of the 2019 International Joint Conference on Neural Networks (IJCNN ’19). IEEE, Budapest, Hungary. 1–8. https://doi.org/10.1109/IJCNN.2019.8851854 Google ScholarCross Ref
- Eclipse JDT. 2023. The Preconditions for Move Instance Method Refactorings. https://github.com/eclipse-jdt/eclipse.jdt.ui/blob/master/org.eclipse.jdt.core.manipulation/core%20extension/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInstanceMethodProcessor.java Google Scholar
- Eclipse JDT. 2023. The Preconditions for Move Static Method Refactorings. https://github.com/eclipse-jdt/eclipse.jdt.ui/blob/master/org.eclipse.jdt.core.manipulation/core%20extension/org/eclipse/jdt/internal/corext/refactoring/structure/MoveStaticMembersProcessor.java Google Scholar
- Thomas Junk. 1999. Confidence Level Computation for Combining Searches with Small Statistics. Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment, 434, 2 (1999), 435–443. https://doi.org/10.1016/S0168-9002(99)00498-2 Google ScholarCross Ref
- René Just, Darioush Jalali, and Michael D Ernst. 2014. Defects4J: A Database of Existing Faults to Enable Controlled Testing Studies for Java Programs. In Proceedings of the 2014 International Symposium on Software Testing and Analysis (ISSTA ’14). ACM, San Jose, CA, USA. 437–440. https://doi.org/10.1145/2610384.2628055 Google ScholarDigital Library
- Amandeep Kaur, Sushma Jain, and Shivani Goel. 2017. A Support Vector Machine Based Approach for Code Smell Detection. In Proceedings of the 2017 International Conference on Machine Learning and Data Science (MLDS ’17). IEEE, Noida, India. 9–14. https://doi.org/10.1109/MLDS.2017.8 Google ScholarCross Ref
- Taskin Kavzoglu. 2009. Increasing the Accuracy of Neural Network Classification Using Refined Training Data. Environmental Modelling & Software, 24, 7 (2009), 850–858. https://doi.org/10.1016/j.envsoft.2008.11.012 Google ScholarDigital Library
- Keras. 2023. Activation Functions. https://github.com/keras-team/keras/blob/master/keras/activations.py Google Scholar
- Miryung Kim, Matthew Gee, Alex Loh, and Napol Rachatasumrit. 2010. Ref-Finder: A Refactoring Reconstruction Tool Based on Logic Query Templates. In Proceedings of the 18th ACM SIGSOFT International Symposium on Foundations of Software Engineering (FSE ’10). ACM, Santa Fe, NM, USA. 371–372. https://doi.org/10.1145/1882291.1882353 Google ScholarDigital Library
- Jochen Kreimer. 2005. Adaptive Detection of Design Flaws. Electronic Notes in Theoretical Computer Science, 141, 4 (2005), 117–136. https://doi.org/10.1016/j.entcs.2005.02.059 Google ScholarDigital Library
- Zarina Kurbatova, Ivan Veselov, Yaroslav Golubev, and Timofey Bryksin. 2020. Recommendation of Move Method Refactoring Using Path-Based Representation of Code. In Proceedings of the 4th International Workshop on Refactoring (IWoR ’20). ACM, Seoul, South Korea. 315–322. https://doi.org/10.1145/3387940.3392191 Google ScholarDigital Library
- Bo Liu. 2023. feTruth. https://github.com/lyoubo/feTruth Google Scholar
- Bo Liu. 2023. Replication Package. https://doi.org/10.5281/zenodo.8267775 Google ScholarCross Ref
- Hui Liu, Jiahao Jin, Zhifeng Xu, and Yifan Bu. 2023. Pre-Trained Word2Vec Model. https://doi.org/10.5281/zenodo.5749111 Google ScholarCross Ref
- Hui Liu, Jiahao Jin, Zhifeng Xu, Yanzhen Zou, Yifan Bu, and Lu Zhang. 2021. Deep Learning Based Code Smell Detection. IEEE Transactions on Software Engineering, 47, 9 (2021), 1811–1837. https://doi.org/10.1109/TSE.2019.2936376 Google ScholarCross Ref
- Hui Liu, Yuting Wu, Wenmei Liu, Qiurong Liu, and Chao Li. 2016. Domino Effect: Move More Methods Once a Method is Moved. In Proceedings of the IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER ’16). IEEE, Osaka, Japan. 1–12. https://doi.org/10.1109/SANER.2016.14 Google ScholarCross Ref
- Hui Liu, Zhifeng Xu, and Yanzhen Zou. 2018. Deep Learning Based Feature Envy Detection. In Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering (ASE ’18). ACM, Montpellier, France. 385–396. https://doi.org/10.1145/3238147.3238166 Google ScholarDigital Library
- Xu-Ying Liu, Jianxin Wu, and Zhi Hua Zhou. 2009. Exploratory Undersampling for Class-Imbalance Learning. IEEE Transactions on Systems, Man, and Cybernetics, Part B (Cybernetics), 39, 2 (2009), 539–550. https://doi.org/10.1109/TSMCB.2008.2007853 Google ScholarDigital Library
- Bafandeh Bahareh Mayvan, Abbas Rasoolzadegan, and Javan Abbas Jafari. 2020. Bad Smell Detection Using Quality Metrics and Refactoring Opportunities. Journal of Software: Evolution and Process, 32, 8 (2020), e2255. https://doi.org/10.1002/smr.2255 Google ScholarDigital Library
- Tom Mens and Tom Tourwé. 2004. A Survey of Software Refactoring. IEEE Transactions on Software Engineering, 30, 2 (2004), 126–139. https://doi.org/10.1109/TSE.2004.1265817 Google ScholarDigital Library
- Tomas Mikolov, Kai Chen, Greg Corrado, and Jeffrey Dean. 2013. Efficient Estimation of Word Representations in Vector Space. In Proceedings of the 1st International Conference on Learning Representations (ICLR ’13). Scottsdale, AZ, USA. 1–12. https://doi.org/10.48550/arXiv.1301.3781 Google ScholarCross Ref
- Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg S Corrado, and Jeff Dean. 2013. Distributed Representations of Words and Phrases and Their Compositionality. In Proceedings of the 27th Annual Conference on Neural Information Processing Systems (NIPS ’13). Curran Associates, Inc., Lake Tahoe, NV, USA. 3111–3119. Google Scholar
- Haris Mumtaz, Mohammad Alshayeb, Sajjad Mahmood, and Mahmood Niazi. 2018. An Empirical Study to Improve Software Security Through the Application of Code Refactoring. Information and Software Technology, 96 (2018), 112–125. https://doi.org/10.1016/j.infsof.2017.11.010 Google ScholarDigital Library
- Fabio Palomba, Gabriele Bavota, Massimiliano Di Penta, Rocco Oliveto, Andrea De Lucia, and Denys Poshyvanyk. 2013. Detecting Bad Smells in Source Code Using Change History Information. In Proceedings of the 28th IEEE/ACM International Conference on Automated Software Engineering (ASE ’13). IEEE, Silicon Valley, CA, USA. 268–278. https://doi.org/10.1109/ASE.2013.6693086 Google ScholarDigital Library
- Fabio Palomba, Gabriele Bavota, Massimiliano Di Penta, Rocco Oliveto, Denys Poshyvanyk, and Andrea De Lucia. 2015. Mining Version Histories for Detecting Code Smells. IEEE Transactions on Software Engineering, 41, 5 (2015), 462–489. https://doi.org/10.1109/TSE.2014.2372760 Google ScholarDigital Library
- Fabio Palomba, Annibale Panichella, Andrea De Lucia, Rocco Oliveto, and Andy Zaidman. 2016. A Textual-Based Technique for Smell Detection. In Proceedings of the 24th IEEE International Conference on Program Comprehension (ICPC ’16). IEEE, Austin, TX, USA. 1–10. https://doi.org/10.1109/ICPC.2016.7503704 Google ScholarCross Ref
- Fabiano Pecorelli, Fabio Palomba, Dario Di Nucci, and Andrea De Lucia. 2019. Comparing Heuristic and Machine Learning Approaches for Metric-Based Code Smell Detection. In Proceedings of the 27th International Conference on Program Comprehension (ICPC ’19). IEEE, Montreal, QC, Canada. 93–104. https://doi.org/10.1109/ICPC.2019.00023 Google ScholarDigital Library
- Hao Peng, Lili Mou, Ge Li, Yuxuan Liu, Lu Zhang, and Zhi Jin. 2015. Building Program Vector Representations for Deep Learning. In Proceedings of the 8th International Conference on Knowledge Science, Engineering and Management (KSEM ’15). Springer, Chongqing, China. 547–553. https://doi.org/10.1007/978-3-319-25159-2_49 Google ScholarDigital Library
- Kyle Prete, Napol Rachatasumrit, Nikita Sudan, and Miryung Kim. 2010. Template-Based Reconstruction of Complex Refactorings. In Proceedings of the 26th IEEE International Conference on Software Maintenance (ICSM ’10). IEEE, Timisoara, Romania. 1–10. https://doi.org/10.1109/ICSM.2010.5609577 Google ScholarDigital Library
- Vitor Sales, Ricardo Terra, Luis Fernando Miranda, and Marco Tulio Valente. 2013. Recommending Move Method Refactorings Using Dependency Sets. In Proceedings of the 20th Working Conference on Reverse Engineering (WCRE ’13). IEEE, Koblenz, Germany. 232–241. https://doi.org/10.1109/WCRE.2013.6671298 Google ScholarCross Ref
- Gerard Salton and Michael J McGill. 1984. Introduction to Modern Information Retrieval. McGraw-Hill, New York, NY, USA. Google ScholarDigital Library
- Tushar Sharma, Vasiliki Efstathiou, Panos Louridas, and Diomidis Spinellis. 2021. Code Smell Detection by Deep Direct-Learning and Transfer-Learning. Journal of Systems and Software, 176 (2021), 110936. https://doi.org/10.1016/j.jss.2021.110936 Google ScholarCross Ref
- Danilo Silva, João Silva, Gustavo Jansen De Souza Santos, Ricardo Terra, and Marco Tulio O Valente. 2021. RefDiff 2.0: A Multi-Language Refactoring Detection Tool. IEEE Transactions on Software Engineering, 47, 12 (2021), 2786–2802. https://doi.org/10.1109/TSE.2020.2968072 Google ScholarCross Ref
- Danilo Silva and Marco Tulio Valente. 2017. RefDiff: Detecting Refactorings in Version Histories. In Proceedings of the 14th International Conference on Mining Software Repositories (MSR ’17). IEEE, Buenos Aires, Argentina. 269–279. https://doi.org/10.1109/MSR.2017.14 Google ScholarDigital Library
- Frank Simon, Frank Steinbruckner, and Claus Lewerentz. 2001. Metrics Based Refactoring. In Proceedings of the 5th European Conference on Software Maintenance and Reengineering (CSMR ’01). IEEE, Lisbon, Portugal. 30–38. https://doi.org/10.1109/CSMR.2001.914965 Google ScholarCross Ref
- Dag IK Sjøberg, Bente Anda, and Audris Mockus. 2012. Questioning Software Maintenance Metrics: A Comparative Case Study. In Proceedings of the 2012 ACM-IEEE International Symposium on Empirical Software Engineering and Measurement (ESEM ’12). ACM, Lund, Sweden. 107–110. https://doi.org/10.1145/2372251.2372269 Google ScholarDigital Library
- Yan-Yan Song and Ying Lu. 2015. Decision Tree Methods: Applications for Classification and Prediction. Shanghai Arch Psychiatry, 27, 2 (2015), 130–135. http://dx.doi.org/10.11919/j.issn.1002-0829.215044 Google ScholarCross Ref
- Ricardo Terra, Marco Tulio Valente, Sergio Miranda, and Vitor Sales. 2018. JMove: A Novel Heuristic and Tool to Detect Move Method Refactoring Opportunities. Journal of Systems and Software, 138 (2018), 19–36. https://doi.org/10.1016/j.jss.2017.11.073 Google ScholarCross Ref
- Martin Thompson. 2023. Aeron. https://github.com/real-logic/aeron/commit/305c060d424fdea13b1b7f2979d545ac7da5f7a5#diff-07eb841a7b48861016496075f986f4c6b330e72f8246e3270be31d9305cbd2bcR104 Google Scholar
- Nikolaos Tsantalis and Alexander Chatzigeorgiou. 2009. Identification of Move Method Refactoring Opportunities. IEEE Transactions on Software Engineering, 35, 3 (2009), 347–367. https://doi.org/10.1109/TSE.2009.1 Google ScholarDigital Library
- Nikolaos Tsantalis, Ameya Ketkar, and Danny Dig. 2022. RefactoringMiner 2.0. IEEE Transactions on Software Engineering, 48, 3 (2022), 930–950. https://doi.org/10.1109/TSE.2020.3007722 Google ScholarCross Ref
- Nikolaos Tsantalis, Matin Mansouri, Laleh Eshkevari, Davood Mazinanian, and Danny Dig. 2018. Accurate and Efficient Refactoring Detection in Commit History. In Proceedings of the 40th International Conference on Software Engineering (ICSE ’18). ACM, Gothenburg, Sweden. 483–494. https://doi.org/10.1145/3180155.3180206 Google ScholarDigital Library
- Aiko Yamashita and Leon Moonen. 2013. Do Developers Care about Code Smells? An Exploratory Survey. In Proceedings of the 20th Working Conference on Reverse Engineering (WCRE ’13). IEEE, Koblenz, Germany. 242–251. https://doi.org/10.1109/WCRE.2013.6671299 Google ScholarCross Ref
- Nico Zazworka, Michele A Shaw, Forrest Shull, and Carolyn Seaman. 2011. Investigating the Impact of Design Debt on Software Quality. In Proceedings of the 2nd Workshop on Managing Technical Debt (MTD ’11). ACM, Honolulu, HI, USA. 17–23. https://doi.org/10.1145/1985362.1985366 Google ScholarDigital Library
Index Terms
- Deep Learning Based Feature Envy Detection Boosted by Real-World Examples
Recommendations
Deep learning based feature envy detection
ASE '18: Proceedings of the 33rd ACM/IEEE International Conference on Automated Software EngineeringSoftware refactoring is widely employed to improve software quality. A key step in software refactoring is to identify which part of the software should be refactored. To facilitate the identification, a number of approaches have been proposed to ...
Deep semantic-Based Feature Envy Identification
Internetware '19: Proceedings of the 11th Asia-Pacific Symposium on InternetwareCode smells regularly cause potential software quality problems in software development. Thus, code smell detection has attracted the attention of many researchers. A number of approaches have been suggested in order to improve the accuracy of code ...
Feature requests-based recommendation of software refactorings
AbstractSoftware requirements are ever-changing which often leads to software evolution. Consequently, throughout software lifetime, developers receive new requirements often expressed as feature requests. To implement the requested features, developers ...
Comments