Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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).

Javier Pérez

May 18, 2014
Tweet

More Decks by Javier Pérez

Other Decks in Programming

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. How should we refactor? Recipes! How to automate these recipes?

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

    the same time • "gaps" are computable Recipes & Refactoring Strategies
  4. 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
  5. 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)
  6. 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
  7. 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
  8. ! "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
  9. V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring

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

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

    Strategy S1 ... Sn R1 ... Rn Available Mature Tools Our challenge Mining Refactoring Strategies
  12. Is this useful / interesting? ! Is this feasible? !

    Who wants to do this? Mine & Reuse Refactoring Strategies?
  13. 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