Skip to content

moar82/RefGen

Repository files navigation

README

RefGen Eclipse plug-in

(c) Copyright 2017 Rodrigo Morales Alvarado

  • Ecole Polytechinique Montreal.
  • Use and copying of this software and preparation of derivative works
  • based upon this software are permitted. Any copy of this software or
  • of any derivative work must include the above copyright notice of
  • Rodrigo Morales Alvarado, this paragraph and the one after it.
  • This software is made available AS IS, and THE AUTHOR DISCLAIMS
  • ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE
  • IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  • PURPOSE, AND NOT WITHSTANDING ANY OTHER PROVISION CONTAINED HEREIN, ANY
  • LIABILITY FOR DAMAGES RESULTING FROM THE SOFTWARE OR ITS USE IS
  • EXPRESSLY DISCLAIMED, WHETHER ARISING IN CONTRACT, TORT (INCLUDING
  • NEGLIGENCE) OR STRICT LIABILITY, EVEN IF Rodrigo Morales Alvarado IS ADVISED
  • OF THE POSSIBILITY OF SUCH DAMAGES.
  • All Rights Reserved.

RefGen plug-in is an Eclipse plug-in developed at Polytechinique de Montreal for performing automatic refactoring of software anti-patterns by Christian Kabulo and Rodrigo Morales. The Eclipse plug-in It is based on the MS dissertation titled "RefACO DEVELOPMENT OF A TOOL FOR AUTOMATIC CODE REFACTORING" by Juan María Frías Hidalgo (University of Malaga), which uses an early version of Ant Colony Optimization developed by Rodrigo Morales.

RefGen implements "RePOR", which is an automatic refactoring approach generated at Polytechnique de Montreal by Rodrigo Morales as part of its Ph.D. Thesis.

RePOR leverage Partial Order reduction to automatically detect, generate and schedule refactoring operations, reducing the search effort (measured in time and number of evaluations) required, compared to state-of the art metaheuristics like Genetic Algorithm and Ant Colony. A research paper on RePOR was submitted to Journal of Systems and Software.

The detection of anti-patterns is based on DECOR, and implemented using the set of tools provided by Ptidej tool suite.

So far, RefGen supports the refactoring of five anti-patterns, namely Blob, Lazy Class, Long-parameter list, spaghetti code, and Speculative Generality.

Why refactoring and why you should care

By continuously improving the design of code, we make it easier and easier to work with. This is in sharp contrast to what typically happens: little refactoring and a great deal of attention paid to expediently adding new features. If you get into the hygienic habit of refactoring continuously, you'll find that it is easier to extend and maintain code. — Joshua Kerievsky, Refactoring to Patterns

Manual refactoring is hard due to:

  • Many options to choose
  • Refactoring solutions can be conflicted, making difficult to decide which refactorings apply and in which order

img1

For all reasons above we developed an automated approach to refactor a system, requiring a minimal interaction from developer.

Are refactoring tools reliable?

As far as I can tell, there is not an automated tool that can totally replace developers. However, software users are relying more and more on automated tools to perform their daily activities. From finding an address using a maps app, to self-driving cars, automated approaches are pervasive, and research communities are pushing forward to simplify daily tasks.

To investigate whether automated refactoring tools affect the understandability of system during code comprehension tasks, we performed an empirical study where: (1) We surveyed 80 developers, asking them to identify from a set of 20 refactoring changes if they were generated by developers or by a tool, and to rate the refactoring changes according to their design quality; (2) we asked 30 developers to complete code comprehension tasks on 10 systems that were refactored by either a freelancer or an automated refactoring tool. To make comparison fair, for a subset of refactoring actions that introduce new code entities, only synthetic identifiers were presented to practitioners. We measured developers’ performance using the NASA task load index for their effort, the time that they spent performing the tasks, and their percentages of correct answers. Our findings, despite current technology limitations, show that it is reasonable to expect refactoring tools to match developer code. Indeed, results show that for 3 out of the 5 anti-pattern types studied, developers could not recognize the origin of the refactoring (i.e., whether it was performed by a human or an automatic tool). We also observed that developers do not prefer human refactorings over automated refactorings, except when refactoring Blob classes; and that there is no statistically significant difference between the impact on code understandability of human refactorings and automated refactorings. We conclude that automated refactorings can be as effective as manual refactorings. However, for complex anti-patterns types like the Blob, the perceived quality achieved by developers is slightly higher.

RefGen plug-in installation and tutorial

Please visit the wiki in this repository for further details. In addition, you can run RefGen in simulation mode (applying refactoring to an abstract model, without modifying your code) to test our tool.

Do not forget to fork our repository to have the latest updates

Research.

If you want to use RefGen in your research, please cite at least the following reference:

  • Morales, R.; Khomh, F.; and Antoniol, G. RePOR: Mimiking humans on refactoring tasks. Are we there yet?. Empirical Software Engineering. 2020 DOI

  • Morales, R.; Chicano, F.; Khomh, F.; and Antoniol, G. Efficient Refactoring Scheduling based on Partial order Reduction. Journal of Systems and Software. 2018 DOI

Here is the list of related research work about automatic refactoring of anti-patterns that I have done in Polytechnique de Montreal in collaboration with other well known researchers. For a complete list of works please visit my personal web site

  • Morales, R. (2015, 2-6 March 2015). Towards a Framework for Automatic Correction of Anti-Patterns. Paper presented at the 2015 IEEE 22nd International Conference on Software Analysis, Evolution, and Reengineering (SANER). DOI

  • Morales, R., Sabane, A., Musavi, P., Khomh, F., Chicano, F., & Antoniol, G. (2016, 14-18 March 2016). Finding the Best Compromise Between Design Quality and Testing Effort During Refactoring. Paper presented at the 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER). DOI

  • Morales, R., Soh, Z., Khomh, F., Antoniol, G., & Chicano, F. On the use of developers’ context for automatic refactoring of software anti-patterns. Volume 128, 2017, Pages 236-251, ISSN 0164-1212, Journal of Systems and Software. DOI

  • Morales, R., Chicano, F., Khomh, F. et al. Exact search-space size for the refactoring scheduling problem. Autom Softw Eng (2017). DOI

  • Morales, R., Saborido, R., Khomh, F., F., Chicano, F., & Antoniol, G, "EARMO: An Energy-Aware Refactoring Approach for Mobile Apps," in IEEE Transactions on Software Engineering, vol. PP, no. 99, pp. 1-1. doi