Skip to Main Content
To facilitate software refactoring, a number of tools have been proposed for code smell detection and for automatic refactoring. However, these tools are passive and human-driven, thus making software refactoring dependent on developers' spontaneity. As a result, software engineers with little experience in software refactoring might miss a number of potential refactorings or may conduct refactorings later than expected. To this end, we propose a monitor-based instant refactoring framework to drive inexperienced software engineers to conduct more refactorings promptly. Changes in the source code are instantly analyzed by a monitor running in background. If these changes have the potential to introduce code smells, the monitor invokes corresponding smell detection tools, and warns developers to resolve detected smells promptly. Feedback from developers is consequently used to optimize smell detection algorithms. The proposed framework has been implemented, evaluated, and compared with the traditional human-driven refactoring approach. Evaluation results suggest that the proposed framework could drive inexperienced engineers to resolve more code smells (by an increase of 140 percent) promptly. The average lifespan of resolved smells was reduced by 92 percent. Results also suggest that the proposed approach could help developers to avoid similar code smells, thus reducing the total number of code smells by 51 percent.