Model‐based source code refactoring with interaction and visual cues
Refactoring source code involves the developer in a myriad of program detail that can obscure the design changes that they actually wish to bring about. On the other hand, refactoring a UML model of the code makes it easier to focus on the program design, but the burdensome task of applying the refa...
Saved in:
| Published in: | Journal of software : evolution and process Vol. 36; no. 5 |
|---|---|
| Main Authors: | , , , |
| Format: | Journal Article |
| Language: | English |
| Published: |
Chichester
Wiley Subscription Services, Inc
01.05.2024
|
| Subjects: | |
| ISSN: | 2047-7473, 2047-7481 |
| Online Access: | Get full text |
| Tags: |
Add Tag
No Tags, Be the first to tag this record!
|
| Summary: | Refactoring source code involves the developer in a myriad of program detail that can obscure the design changes that they actually wish to bring about. On the other hand, refactoring a UML model of the code makes it easier to focus on the program design, but the burdensome task of applying the refactorings to the source code is left to the developer. In an attempt to obtain the advantages of both approaches, we propose a refactoring approach where the interaction with the developer takes place at the model level, but the actual refactoring occurs on the source code itself. We call this approach model‐based source code refactoring and implement it in this paper using two tools: (1) Design‐Imp enables the developer to use interactive search‐based design exploration to create a UML‐based desired design from an initial design extracted from the source code. It also provides visual cues to improve developer comprehension during the design‐level refactoring process and to help the developer to discern between promising and poor refactoring solutions. (2) Code‐Imp then refactors the original source so that it has the same functional behavior as the original program, and a design close to the one produced in the design exploration phase, that is, a design that has been confirmed as “desirable” by the developer. We evaluated our approach involving interaction and visual cues with industrial developers refactoring three Java projects, comparing it with an approach using interaction without visual cues and a fully automated approach. The results show that our approach yields refactoring sequences that are more acceptable both to the individual developer and to a set of independent expert refactoring evaluators. Furthermore, our approach removed more code smells and was evaluated very positively by the experiment participants.
We present an interactive model‐based source code refactoring approach that combines qualitative and quantitative evaluation criteria that improve the identification of refactoring opportunities as well as enhance developer assessment of refactoring value. Initially a UML‐like design model is extracted from the source code and used by an evolutionary algorithm to produce a refactored model. Proposed refactorings are highlighted using visual cues and presented to the developer for their evaluation. Developer feedback is included in the later iterations of the algorithm. The source code is finally refactored based on the refactorings accepted by the developer. Our experimental results show that this approach yields refactoring sequences that are more acceptable both to the individual developer and to a set of independent expert refactoring evaluators. Furthermore, our approach removes more code smells and was evaluated very positively by the experiment participants. |
|---|---|
| Bibliography: | ObjectType-Article-1 SourceType-Scholarly Journals-1 ObjectType-Feature-2 content type line 14 |
| ISSN: | 2047-7473 2047-7481 |
| DOI: | 10.1002/smr.2596 |