[Paper Review] Making refactoring decisions in large-scale Java systems: an empirical stance
This paper proposes a metric-based approach to identify key classes in large-scale Java systems for refactoring, combining potential gain (PG) for inheritance and aggregation coupling with class features like method and attribute counts. The study finds substantial system-specific differences in key class characteristics, with Ant being the only system aligning with expected key class patterns, and highlights that metrics from other domains (e.g., web search) can be adapted to software engineering for targeted refactoring decisions.
Decisions on which classes to refactor are fraught with difficulty. The problem of identifying candidate classes becomes acute when confronted with large systems comprising hundreds or thousands of classes. In this paper, we describe a metric by which key classes, and hence candidates for refactoring, can be identified. Measures quantifying the usage of two forms of coupling, inheritance and aggregation, together with two other class features (number of methods and attributes) were extracted from the source code of three large Java systems. Our research shows that metrics from other research domains can be adapted to the software engineering process. Substantial differences were found between each of the systems in terms of the key classes identified and hence opportunities for refactoring those classes varied between those systems.
Motivation & Objective
- To address the lack of systematic criteria for selecting classes for refactoring in large-scale Java systems.
- To identify key classes that are central to system structure and thus prime candidates for refactoring.
- To evaluate whether metrics from other domains (e.g., web search) can be adapted to software engineering for refactoring decision support.
- To investigate differences in key class characteristics across diverse Java systems, including libraries and applications.
- To validate the hypothesis that key classes are typically located at the base of inheritance hierarchies.
Proposed method
- Adapted the Potential Gain (PG) metric—originally used in web search— to measure class centrality based on inheritance and aggregation coupling in UML class diagrams.
- Extracted four class-level features: number of methods, number of attributes, inheritance coupling, and aggregation coupling from three large Java systems (JDK, Ant, Tomcat).
- Computed PG scores for each class using graph-based analysis of inheritance and aggregation relationships to rank class importance.
- Combined PG scores with raw counts of methods and attributes to identify candidate key classes for refactoring.
- Conducted a meta-analysis of Fowler’s 72 refactorings to justify the selection of core refactoring patterns (e.g., Move Field, Move Method) that depend on coupling and class size.
- Used dependency analysis to identify core refactorings and justify the focus on aggregation, inheritance, and class size as key indicators of refactoring need.
Experimental results
Research questions
- RQ1Which classes in large-scale Java systems are most suitable for refactoring, and what criteria can reliably identify them?
- RQ2To what extent can metrics from other domains—specifically the Potential Gain metric—be effectively repurposed for class-level refactoring decision-making?
- RQ3Are key classes consistently located at the base of inheritance hierarchies, as suggested by prior conjectures?
- RQ4How do the characteristics of key classes (e.g., number of methods, attributes, constructors, coupling) vary across different types of systems (e.g., application vs. library-based)?
- RQ5What is the relationship between core refactoring patterns (e.g., Move Field, Move Method) and the structural features of key classes?
Key findings
- The Potential Gain metric successfully identified key classes in all three systems, demonstrating that metrics from other domains can be effectively adapted to software engineering for refactoring prioritization.
- Substantial differences were found between systems: JDK had significantly more constructors (mean 1.242) than Ant (1.073) and Tomcat (1.069), indicating distinct structural patterns.
- Only the Ant system exhibited the expected characteristics of key classes as defined by conjecture C1, suggesting that key classes are not consistently located at the base of inheritance hierarchies.
- The meta-analysis revealed that Move Field and Move Method are core refactorings dependent on aggregation and coupling, justifying their inclusion as indicators of refactoring need.
- Large Class and Primitive Obsession code smells were prevalent in key classes, supporting the use of high method and attribute counts as indicators of refactoring urgency.
- The study supports prior findings on power laws in software design, suggesting interfaces often serve as surrogates for multiple inheritance, especially in complex systems.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.