Applicability of Lambda Expressions in Refactoring Near-Miss Micro-Clones in Java

Mehedi Hasan Shanto, Manishankar Mondal, Muhammad Asaduzzaman · Advances in intelligent systems research/Advances in Intelligent Systems Research · 2025

Duplicate code fragments, known as code clones, are a widespread phenomenon in software development, often causing difficulties in the maintenance and evolution of software systems.Micro-clones refer to short code fragments (i.e., less than five lines in length), which are particularly prevalent in the codebase.This study investigates the application of lambda expressions-a Java 8 functionality that enables the generation of concise and functional code segments, as a refactoring strategy for micro-clones.We focused and identified near-miss microclones of across five distinct subject systems using the NiCad clone detector.We have chosen 425 near-miss micro-clone pairs to ensure a 95% confidence level with a 5% confidence interval, based on the clone detector results for thorough investigation.Our findings indicate that 69.4% of these pairs can be refactored utilizing lambda refactoring technique.We also built a classifier using significant features based on Mann-Whitney-Wilcoxon U Test results from the microclones that achieved 78.91% accuracy.The effectiveness of lambda expressions in minimizing repetition, enhancing maintainability, and parameterizing the small changes in behavior among micro-clone fragments was verified by their feedback.We enhance the overall understanding of refactoring techniques and offer developers real insights to optimize their code bases.

Read the paper · More papers on PaperTik