Identifying Method Friendships to Remove the Feature Envy Bad Smell

Rocco Oliveto, Malcom Gethers, Gabriele Bavota, Denys Poshyvanyk, and Andrea De Lucia
University of Molise, Italy; College of William and Mary, USA; University of Salerno, Italy
Tools & Languages

We propose a novel approach to identify Move Method refactoring opportunities and remove the Feature Envy bad smell from source code. The proposed approach analyzes both structural and conceptual relationships between methods and uses Relational Topic Models (RTM) to identify sets of methods that share several responsibilities, i.e., "friend methods". The analysis of method friendships of a given method can be used to pinpoint the target class (envied class) where the method should be moved in. The results of a preliminary empirical evaluation indicate that the proposed approach provides accurate and meaningful refactoring opportunities.