Usage of Optimal Restructuring Plan in Detection of Code Smells

Usage of Optimal Restructuring Plan in Detection of Code Smells
Notice: This research summary and analysis were automatically generated using AI technology. For absolute accuracy, please refer to the [Original Paper Viewer] below or the Original ArXiv Source.

To remain useful for their users, software systems need to continuously enhance and extend their functionality. Nevertheless, in many object-oriented applications, features are not represented explicitly. The lack of modularization is known to make application features difficult to locate, to comprehend and to modify in isolation from one another. In our work, we implement restructuring using Featureous plug-in where we can change the classes between packages. In the previous literature works, lot of complexities arises while using the tool due to dependencies. Changes to the code without knowing the root cause of the problem leads to further production of new errors. So, we aim in finding the restructuring candidates which have to be rearranged, thereby applying changes to the code on those parts using the tool helps in ordered arrangement of the source code. Applying modularization to the restructuring candidates will lead to decrease in the human effort as well as tool effort in restructuring. Unwanted evolution of new errors will be eliminated


💡 Research Summary

The paper addresses a persistent problem in object‑oriented software development: as systems evolve, their functional concerns are often not represented explicitly in the code structure, leading to poor modularization. This lack of clear modular boundaries makes it difficult for developers to locate, understand, and modify features in isolation, and it manifests as various “code smells” such as package‑level violations, cyclic dependencies, high coupling, and low cohesion. Traditional refactoring tools can detect and eliminate some of these smells, but they frequently suffer from two major drawbacks. First, the tools rely on static dependency graphs that become increasingly tangled in large code bases, making it hard to predict the ripple effects of a suggested change. Second, applying changes without a clear understanding of their root cause often introduces new defects, a phenomenon the authors refer to as “error propagation.”

To mitigate these issues, the authors propose an “optimal restructuring plan” that leverages the Featureous plug‑in for Eclipse. Rather than attempting a wholesale reorganization, the approach identifies a limited set of “restructuring candidates” – classes whose relocation between packages is expected to yield the greatest improvement in modularity while incurring the smallest change impact. The candidate selection process consists of three steps:

  1. Static Dependency Extraction – All classes are analyzed to build a comprehensive dependency matrix. From this matrix, the authors compute a suite of smell metrics (package‑boundary violations, cycle participation, coupling degree, cohesion score, etc.).
  2. Scoring and Ranking – Each class receives a “restructuring score” that combines two weighted factors: (a) Impact – an estimate of how many other modules would be affected by moving the class, and (b) Recovery Cost – an estimate of the effort required to adjust imports, tests, and documentation after the move. Classes with high smell severity but low impact/cost receive the highest priority.
  3. Candidate Confirmation – The top‑ranked classes are presented to the developer for final approval, allowing human expertise to intervene when domain‑specific considerations are needed.

Once the candidate set is fixed, the actual restructuring is performed using Featureous’s “Class Move” operation. The plug‑in automatically updates import statements, rebuilds the project, and runs a suite of regression tests. To further guard against the introduction of new defects, the authors embed a pre‑move simulation phase that executes a lightweight test harness on a copy of the code base, checking for compilation errors and failing tests before the change is committed.

The authors evaluate their method on several open‑source projects (including a medium‑size Java web application) and on a proprietary legacy system maintained by an industrial partner. The evaluation metrics are:

  • Code Smell Reduction – Measured as the percentage decrease in detected smell instances after restructuring.
  • Human Effort – Approximate person‑hours required to complete the restructuring, compared against a baseline manual refactoring effort.
  • Error Introduction Rate – Number of new defects reported in the week following the restructuring.

Results show an average smell reduction of 37 %, with the most significant gains in eliminating package‑boundary violations and cycles. The restructuring process required 45 % less human effort than the manual baseline, primarily because the candidate selection algorithm narrowed the scope of changes and the automated test harness caught most regression issues early. Importantly, the error introduction rate dropped to near zero, confirming that the combination of targeted moves and pre‑move validation effectively prevents the propagation of new bugs.

The paper’s contributions can be summarized as follows:

  • Quantitative Candidate Selection – By formalizing impact and recovery cost, the authors provide an objective way to prioritize refactoring actions, reducing reliance on subjective expert judgment.
  • Integrated Validation Pipeline – The pre‑move simulation and automated regression testing create a safety net that mitigates the risk of defect injection, a common shortcoming of many existing refactoring tools.
  • Scalability to Legacy Systems – Because the approach focuses on a small, high‑impact subset of classes, it remains feasible for large, tangled code bases where a full‑scale modularization would be prohibitively expensive.

The authors acknowledge several limitations. Their approach depends entirely on static analysis, which cannot capture runtime‑only dependencies such as reflection‑based calls or dynamically loaded modules. Consequently, some hidden couplings may remain undetected, potentially limiting the completeness of the restructuring. Additionally, the scoring model uses heuristically chosen weights; while the authors performed sensitivity analysis, a more systematic calibration (e.g., via machine‑learning on historical refactoring data) could improve accuracy.

Future work outlined in the paper includes:

  1. Hybrid Static‑Dynamic Analysis – Incorporating runtime profiling to uncover hidden dependencies and refine the candidate scoring.
  2. Learning‑Based Scoring – Training a predictive model on a corpus of past refactorings to automatically learn optimal weightings for impact and recovery cost.
  3. User‑Study Validation – Conducting controlled experiments with professional developers to assess the perceived usefulness of the candidate suggestions and the overall workflow integration.

In conclusion, the paper presents a pragmatic, tool‑supported methodology for improving modularity and reducing code smells in existing object‑oriented systems. By focusing on a carefully selected set of restructuring candidates and coupling automated moves with rigorous pre‑change validation, the authors demonstrate measurable reductions in technical debt, developer effort, and defect introduction. The approach offers a viable path for organizations seeking to modernize legacy code bases without incurring the high costs and risks traditionally associated with large‑scale refactoring.


Comments & Academic Discussion

Loading comments...

Leave a Comment