Save 37% off PRO during our Black Friday Sale! »

Can we Mine and Reapply Refactoring Strategies?

Can we Mine and Reapply Refactoring Strategies?

I believe reuse is the single most beneficial strategy in software engineering and it can be fostered by harnessing today’s wide available data and extensive collaborative software development environment. In this context, I want to propose a challenge. Can we mine and reuse successful complex refactoring strategies? In the past I have developed a technique to compute refactoring plans –complex refactoring sequences– from refactoring strategies for
correcting bad smells, using automated planning. The future challenge I present involves studying: how to analyse software projects’ history to identify refactoring patterns that were successful in the past for removing bad smells; and how to collect and represent these strategies so they can be automatically re-applied in other projects. Presented at the Dagstuhl seminar: “The Future of Refactoring” (http://www.dagstuhl.de/14211).

7e6a5857a7eb4501c63ab00481ac3305?s=128

Javier Pérez

May 18, 2014
Tweet

Transcript

  1. May 18 – 23, 2014, Dagstuhl Seminar “The Future of

    Refactoring” Javier Pérez Can we mine and reapply refactoring strategies? Ansymo - University of Antwerp - Belgium
  2. Can we mine refactoring strategies? Can we automate refactoring strategies?

  3. Can we mine refactoring strategies? Can we automate refactoring strategies?

  4. How should we refactor? Recipes! How to automate these recipes?

    Bad Smells Disharmonies to / away patterns
  5. Refactoring Strategy • incrementally composable • formal & vague at

    the same time • "gaps" are computable Recipes & Refactoring Strategies
  6. Automated Planning ? A S1 S2

  7. Automated Planning ? A S1 S2

  8. Hierarchical Task Network (HTN) Planning • Tasks: Methods and operators

    - “recipes” on how to execute a task • Preconditions: first-order-logic queries - gather system information • Goal: Execute a task method1 precondition1 task1 task2 task3 ... method2 precondition2 task4 operator1 precondition3 ADD DEL Goal Execute a task
  9. Remove Data Class Strategy remove-data-class all-sts (class) remove-data-class reorganize-class (class)

    remove-class (class) remove-data-class trivial (class) refactoring alt apply strategy (refact.) strategy (smell) remove-data-class clean-class (class) encapsulate-field (field, getter-name, setter-name) encapsulate-fields non-private (class) remove-getters unused (class) remove-setters unsued (class) remove-feature-envy move-method-to-envied-class (method, env-class) move-method all-sts (method, tgt-class, reference) remove-method (accessor) remove-data-class move-fe-methods (class) remove-data-class move-client-methods (class)
  10. Remove Data Class Strategy remove-data-class all-sts (class) remove-data-class reorganize-class (class)

    remove-class (class) remove-data-class trivial (class) refactoring alt apply strategy (refact.) strategy (smell) remove-data-class clean-class (class) encapsulate-field (field, getter-name, setter-name) encapsulate-fields non-private (class) remove-getters unused (class) remove-setters unsued (class) remove-feature-envy move-method-to-envied-class (method, env-class) move-method all-sts (method, tgt-class, reference) remove-method (accessor) remove-data-class move-fe-methods (class) remove-data-class move-client-methods (class) • preconditions • control structures • strategies composition • code queries • metrics • user queries
  11. Refactoring Planning increase visibility! move method! increase visibility! move method!

    increase visibility! increase visibility! increase visibility! move method! encapsulate field! remove-method! remove-method! remove-method Remove Data Class! Current Source Code Refactoring Strategy
  12. ! "Computation of refactoring plans from refactoring strategies using HTN

    planing” J. Pérez, Y. Crespo, WRT 2012 ! ! “Refactoring Planning for Design Smell Correction in Object- Oriented Software” Javier Pérez, PhD Thesis, July 2011, University of Valladolid More information
  13. Can we mine refactoring strategies? Can we automate refactoring strategies?

  14. Can we mine refactoring strategies? Can we automate refactoring strategies?

    Yes!
  15. Can we mine refactoring strategies? Can we automate refactoring strategies?

    Yes!
  16. Mining Refactoring Strategies Refactoring Strategy

  17. Mining Refactoring Strategies Refactoring Strategy

  18. V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring

    Strategy S1 ... Sn R1 ... Rn Mining Refactoring Strategies
  19. V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring

    Strategy S1 ... Sn R1 ... Rn Available Mature Tools Mining Refactoring Strategies
  20. V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring

    Strategy S1 ... Sn R1 ... Rn Available Mature Tools Our challenge Mining Refactoring Strategies
  21. Can we mine refactoring strategies? Can we automate refactoring strategies?

    Yes!
  22. Can we mine refactoring strategies? Can we automate refactoring strategies?

    Yes! ?????
  23. Is this useful / interesting? ! Is this feasible? !

    Who wants to do this? Mine & Reuse Refactoring Strategies?
  24. May 18 – 23, 2014, Dagstuhl Seminar “The Future of

    Refactoring” Javier Pérez Can we mine and reapply refactoring strategies? Ansymo - University of Antwerp - Belgium