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

Computation of Refactoring Plans from Refactori...

Computation of Refactoring Plans from Refactoring Strategies using HTN Planning

Complex refactoring processes, such as applying big refactorings or removing design smells are difficult to perform in practice. The complexity of these processes is partly due to their heuristic nature and to the constraints imposed by preconditions on the applicability of the individual refactorings. We introduce refactoring strategies as heuristic-based, automation-suitable specifications of a complex refactoring process. They allow us to specify correction strategies and big refactorings more formally than it is done in current catalogues. Refactoring strategies can be instantiated, for each particular case, into refactoring plans. We define refactoring plans as sequences of refactorings that are immediately applicable over the current system source code. We have developed an approach for instantiating refactoring strategies into refactoring plans that uses Hierarchical Task Network (HTN) planning. This paper describes this approach and presents a case study, in order to evaluate and characterise it. Presented at WRT 2012 (http://www.ifs.hsr.ch/WRT2012.7401.0.html).

Javier Pérez

July 01, 2012
Tweet

More Decks by Javier Pérez

Other Decks in Research

Transcript

  1. Computation of Refactoring Plans from Refactoring Strategies using HTN Planning

    WRT2012 June 1st - Rapperswil, Switzerland Javier Pérez Université de Mons, Belgium [email protected] Yania Crespo Universidad de Valladolid, Spain [email protected]
  2. PrintServer formatSummary(): String setLastDocument(d: Document): void getLastDocument: Document printDocument(): void

    lastDocument: Document formatDocument: String formatSummary(): String content: String name: String author: String creationDate: Date Document The problem to solve: complex refactoring processes ✤ formatSummary() of PrintServer suffers from Feature Envy ✤ Trivial strategy: apply Move Method from PrintServer to Document ✤ Refactoring precondition violation: same signature conflict ✤ Additional refactorings are needed to enable the precondition ✤ Different refactoring sequences for each particular case
  3. PrintServer formatSummary(): String setLastDocument(d: Document): void getLastDocument: Document printDocument(): void

    lastDocument: Document formatDocument: String formatSummary(): String content: String name: String author: String creationDate: Date Document The problem to solve: complex refactoring processes ✤ formatSummary() of PrintServer suffers from Feature Envy ✤ Trivial strategy: apply Move Method from PrintServer to Document ✤ Refactoring precondition violation: same signature conflict ✤ Additional refactorings are needed to enable the precondition ✤ Different refactoring sequences for each particular case
  4. PrintServer formatSummary(): String setLastDocument(d: Document): void getLastDocument: Document printDocument(): void

    lastDocument: Document formatDocument: String formatSummary(): String content: String name: String author: String creationDate: Date Document The problem to solve: complex refactoring processes ✤ formatSummary() of PrintServer suffers from Feature Envy ✤ Trivial strategy: apply Move Method from PrintServer to Document ✤ Refactoring precondition violation: same signature conflict ✤ Additional refactorings are needed to enable the precondition ✤ Different refactoring sequences for each particular case
  5. PrintServer formatSummary(): String setLastDocument(d: Document): void getLastDocument: Document printDocument(): void

    lastDocument: Document formatDocument: String formatSummary(): String content: String name: String author: String creationDate: Date Document The problem to solve: complex refactoring processes ✤ formatSummary() of PrintServer suffers from Feature Envy ✤ Trivial strategy: apply Move Method from PrintServer to Document ✤ Refactoring precondition violation: same signature conflict ✤ Additional refactorings are needed to enable the precondition ✤ Different refactoring sequences for each particular case
  6. The problem to solve ✤ What is the problem? ✦

    Automated or semi-automated support ✦ To schedule sequences of refactorings (refactoring plans) ✦ To perform complex refactoring processes ‣ big refactorings ‣ introduce / remove a design pattern ‣ remove design smells ✤ Why is it a problem? ✦ Refactoring sequences have to be planned ahead for each case ✦ Preconditions can disable the application of a refactoring over the current system
  7. The problem to solve ✤ What is the problem? ✦

    Automated or semi-automated support ✦ To schedule sequences of refactorings (refactoring plans) ✦ To perform complex refactoring processes ‣ big refactorings ‣ introduce / remove a design pattern ‣ remove design smells ✤ Why is it a problem? ✦ Refactoring sequences have to be planned ahead for each case ✦ Preconditions can disable the application of a refactoring over the current system
  8. The idea ✤ Define an integrated way to describe recipes

    and refactorings, that could be automatically applied ✤ Given a recipe / heuristic of a complex refactoring process, compute the precise instance of that recipe for a particular case source code refactoring recipe ? refactoring sequence
  9. Proposal: Refactoring Strategies and Refactoring Plans Refactoring Strategies ✦ heuristic-based

    specifications ✦ automation-suitable ✦ describe complex behaviour-preserving transformations ✦ aimed at a certain goal Refactoring Plans ✦ sequences of instantiated transformations ✦ achieve a certain goal ✦ can be applied over a system in its current state ✦ behaviour-preserving transformation sequence
  10. Proposal: Refactoring Strategies and Refactoring Plans Refactoring Strategies ✦ heuristic-based

    specifications ✦ automation-suitable ✦ describe complex behaviour-preserving transformations ✦ aimed at a certain goal Refactoring Plans ✦ sequences of instantiated transformations ✦ achieve a certain goal ✦ can be applied over a system in its current state ✦ behaviour-preserving transformation sequence
  11. Proposal: Refactoring Strategies and Refactoring Plans Refactoring Strategies ✦ heuristic-based

    specifications ✦ automation-suitable ✦ describe complex behaviour-preserving transformations ✦ aimed at a certain goal Refactoring Plans ✦ sequences of instantiated transformations ✦ achieve a certain goal ✦ can be applied over a system in its current state ✦ behaviour-preserving transformation sequence
  12. Characteristics of the problem ✤ Refactoring specifications ✦ representation at

    a low level of detail of ‣ preconditions and effects ✦ support for reasoning about refactoring execution and computation: ‣ preconditions and effects ✤ Heuristic descriptions of refactoring strategies ✦ refactoring knowledge is empirically compiled in natural language. These heuristics are hard to specify in an algorithmic language ✦ steps, loops and alternatives with unspecified order or without decision conditions ✦ incremental improvement of the available knowledge ✦ alternative correction strategies ✤ Additional elements in refactoring strategies ✦ invocation of strategies and substrategies ✦ calls for user interaction
  13. Automated Planning Automated planning is an artificial intelligence technique to

    compute the sequences of actions that will achieve a certain goal when they are performed. ✤ Example: getting apples and a book: ✤ Actions defined with preconditions and effects: not (have (X)) => buy(X) => have(X) State of the world: at (grocery) AND not (have (apples)) AND not (have (book)) Actions: buy (apples); moveTo (bookstore) Goals: have (book) AND have (apples)
  14. Hierarchical Task Network (HTN) Planning ✤ Tasks: Methods and operators

    - “recipes” about 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
  15. Hierarchical Task Network (HTN) Planning ✤ Tasks: Methods and operators

    - “recipes” about 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
  16. Hierarchical Task Network (HTN) Planning ✤ Tasks: Methods and operators

    - “recipes” about 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
  17. Hierarchical Task Network (HTN) Planning ✤ Tasks: Methods and operators

    - “recipes” about 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
  18. Hierarchical Task Network (HTN) Planning ✤ Tasks: Methods and operators

    - “recipes” about 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
  19. Hierarchical Task Network (HTN) Planning ✤ Tasks: Methods and operators

    - “recipes” about 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
  20. Hierarchical Task Network (HTN) Planning ✤ Tasks: Methods and operators

    - “recipes” about 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
  21. Hierarchical Task Network (HTN) Planning ✤ Tasks: Methods and operators

    - “recipes” about 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
  22. Hierarchical Task Network (HTN) Planning ✤ Tasks: Methods and operators

    - “recipes” about 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
  23. Refactoring Planning as an HTN Planning Problem ✤ JSHOP2: the

    HTN planner selected ✦ forward search in the same order as the plan should be executed ✦ very expressive and efficient ✦ first-order-logic inference engine ✦ external queries 5.3. JSHOP2: A HIERARCHICAL TASK NETWORK PLANNER 91 World’s state: AST represented by first-order logic predicates Operators: atomic changes to the AST (mainly add, delete and replace) Tasks: transformation parts refactoring parts non-behaviour preserving transformations refactorings refactoring strategies Goal: Executing a smell correction strategy Executing a refactoring application strategy Planning problem: Execute a particular refactoring strategy over a particular ver- sion of a system Table 5.5: Interpretation of the refactoring planning problem as an HTN planning problem. atomic transformations –add, delete and replace– over the basic elements of the AST. Refactor- ng strategies, simpler refactorings and non-behaviour-preserving transformations (NBPT) are mplemented as tasks, which can be further decomposed into other tasks. This decomposition construct will allow us to split strategies into simpler ones and to attach preconditions to them. Therefore, this allows dependencies to be specified, and to avoid conflicts between behaviour- preserving transformations or parts of them. Invocation of transformations, refactorings and
  24. Eclipse + JTransformer iPlasma JSHOP2 Smells Java Source Code Java

    Program Element Facts Scripts Refactoring Planning Domain Refactoring Planning Problem Refactoring Plan HTN Domain Definition System's Initial State Prototype Overview ✤ Refactoring Planning Domain: strategies + refactorings + NBPT + queries ✤ JTransformer: to obtain a predicate-based representation of the system ✤ iPlasma: to produce smell-entity reports ✤ JSHOP2: to compute refactoring plans from strategies for a particular case
  25. Eclipse + JTransformer iPlasma JSHOP2 Smells Java Source Code Java

    Program Element Facts Scripts Refactoring Planning Domain Refactoring Planning Problem Refactoring Plan HTN Domain Definition System's Initial State Prototype Overview ✤ Refactoring Planning Domain: strategies + refactorings + NBPT + queries ✤ JTransformer: to obtain a predicate-based representation of the system ✤ iPlasma: to produce smell-entity reports ✤ JSHOP2: to compute refactoring plans from strategies for a particular case
  26. Eclipse + JTransformer iPlasma JSHOP2 Smells Java Source Code Java

    Program Element Facts Scripts Refactoring Planning Domain Refactoring Planning Problem Refactoring Plan HTN Domain Definition System's Initial State Prototype Overview ✤ Refactoring Planning Domain: strategies + refactorings + NBPT + queries ✤ JTransformer: to obtain a predicate-based representation of the system ✤ iPlasma: to produce smell-entity reports ✤ JSHOP2: to compute refactoring plans from strategies for a particular case
  27. Eclipse + JTransformer iPlasma JSHOP2 Smells Java Source Code Java

    Program Element Facts Scripts Refactoring Planning Domain Refactoring Planning Problem Refactoring Plan HTN Domain Definition System's Initial State Prototype Overview ✤ Refactoring Planning Domain: strategies + refactorings + NBPT + queries ✤ JTransformer: to obtain a predicate-based representation of the system ✤ iPlasma: to produce smell-entity reports ✤ JSHOP2: to compute refactoring plans from strategies for a particular case
  28. Eclipse + JTransformer iPlasma JSHOP2 Smells Java Source Code Java

    Program Element Facts Scripts Refactoring Planning Domain Refactoring Planning Problem Refactoring Plan HTN Domain Definition System's Initial State Prototype Overview ✤ Refactoring Planning Domain: strategies + refactorings + NBPT + queries ✤ JTransformer: to obtain a predicate-based representation of the system ✤ iPlasma: to produce smell-entity reports ✤ JSHOP2: to compute refactoring plans from strategies for a particular case
  29. Eclipse + JTransformer iPlasma JSHOP2 Smells Java Source Code Java

    Program Element Facts Scripts Refactoring Planning Domain Refactoring Planning Problem Refactoring Plan HTN Domain Definition System's Initial State Prototype Overview ✤ Refactoring Planning Domain: strategies + refactorings + NBPT + queries ✤ JTransformer: to obtain a predicate-based representation of the system ✤ iPlasma: to produce smell-entity reports ✤ JSHOP2: to compute refactoring plans from strategies for a particular case
  30. Eclipse + JTransformer iPlasma JSHOP2 Smells Java Source Code Java

    Program Element Facts Scripts Refactoring Planning Domain Refactoring Planning Problem Refactoring Plan HTN Domain Definition System's Initial State Prototype Overview ✤ Refactoring Planning Domain: strategies + refactorings + NBPT + queries ✤ JTransformer: to obtain a predicate-based representation of the system ✤ iPlasma: to produce smell-entity reports ✤ JSHOP2: to compute refactoring plans from strategies for a particular case
  31. Eclipse + JTransformer iPlasma JSHOP2 Smells Java Source Code Java

    Program Element Facts Scripts Refactoring Planning Domain Refactoring Planning Problem Refactoring Plan HTN Domain Definition System's Initial State Prototype Overview ✤ Refactoring Planning Domain: strategies + refactorings + NBPT + queries ✤ JTransformer: to obtain a predicate-based representation of the system ✤ iPlasma: to produce smell-entity reports ✤ JSHOP2: to compute refactoring plans from strategies for a particular case
  32. Eclipse + JTransformer iPlasma JSHOP2 Smells Java Source Code Java

    Program Element Facts Scripts Refactoring Planning Domain Refactoring Planning Problem Refactoring Plan HTN Domain Definition System's Initial State Prototype Overview ✤ Refactoring Planning Domain: strategies + refactorings + NBPT + queries ✤ JTransformer: to obtain a predicate-based representation of the system ✤ iPlasma: to produce smell-entity reports ✤ JSHOP2: to compute refactoring plans from strategies for a particular case
  33. Eclipse + JTransformer iPlasma JSHOP2 Smells Java Source Code Java

    Program Element Facts Scripts Refactoring Planning Domain Refactoring Planning Problem Refactoring Plan HTN Domain Definition System's Initial State Prototype Overview ✤ Refactoring Planning Domain: strategies + refactorings + NBPT + queries ✤ JTransformer: to obtain a predicate-based representation of the system ✤ iPlasma: to produce smell-entity reports ✤ JSHOP2: to compute refactoring plans from strategies for a particular case
  34. Eclipse + JTransformer iPlasma JSHOP2 Smells Java Source Code Java

    Program Element Facts Scripts Refactoring Planning Domain Refactoring Planning Problem Refactoring Plan HTN Domain Definition System's Initial State Prototype Overview ✤ Refactoring Planning Domain: strategies + refactorings + NBPT + queries ✤ JTransformer: to obtain a predicate-based representation of the system ✤ iPlasma: to produce smell-entity reports ✤ JSHOP2: to compute refactoring plans from strategies for a particular case
  35. Refactoring Planning Domain ✤ 3 Refactoring Strategies: ✦ for applying

    a complex refactoring ‣ Move Method ✦ for removing design smells ‣ Remove Data Class and Remove Feature Envy ✤ 9 Refactorings: ✦ Encapsulate Field, Move Method, Rename Method, Rename Field, Rename Parameter, Rename Local Variable, Remove Field, Remove Method and Remove Class. ✤ > 150 program queries: ✦ structural, lexical, numerical (metrics), user queries ✦ 8 external Java procedures
  36. Refactoring Strategies ✤ Non-Behaviour-Preserving transformations ✦ building blocks for other

    transformations ✤ Refactorings ✦ can include: simple queries, atomic AST changes, NBP transformations, deterministic control constructs ✤ Refactoring strategies ✦ can include: complex queries, atomic AST changes, any transformation, non-deterministic control constructs ✦ aimed at a goal (apply big refactorings, remove smells) Refactoring Strategy Refactoring Non-Behaviour-Preserving Transformation Behaviour-Preserving Transformation Transformation 0..* 1..* 0..* 0..* 0..1 1..*
  37. Refactoring - Rename Parameter (:method (rename-parameter ?package ?class ?method ?old-parameter-name

    ? new-parameter-name) ;;Precondition ( ; new-name doesnt conflict (get-method-id ?package ?class ?method ?method-id) (paramDefT ?param-id ?method-id ?TYPE ?old-parameter-name) (not (visible-in-method ?new-parameter-name ?method-id)) ) ;;Task list ( (!rep (paramDefT ?param-id ?method-id ?TYPE ?old-parameter-name) (paramDefT ?param-id ?method-id ?TYPE ?new-parameter-name) ) (rename-variable-accesses ?param-id ?old-parameter-name ?new- parameter-name) ) )
  38. Refactoring - Rename Parameter (:method (rename-variable-accesses ?var-id ?old-name ?new-name) non-renamed-accesses

    ;;Precondition (:first ;iteration's ordering does not matter ( ; get non-renamed accesses (identT ?pef-id ?parent ?encl ?old-name ?var-id) ) ) ;;Task list ( (!rep (identT ?pef-id ?parent ?encl ?old-name ?var-id) (identT ?pef-id ?parent ?encl ?new-name ?var-id) ) ;loop (rename-variable-accesses ?var-id ?old-name ?new-name) ) no-more-non-renamed-accesses ();;Precondition ();;Task list )
  39. 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)
  40. 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)
  41. 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)
  42. 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)
  43. 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)
  44. 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)
  45. 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)
  46. 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)
  47. 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)
  48. Refactoring Strategy Fragment - Remove DataClass (:method (remove-data-class all-sts ?package-name

    ?class-name) ( (class-fqn ?class ?package-name ?class-name) ) ( (remove-data-class all-sts ?class) ) ) (:method (remove-data-class all-sts ?class) () ( (remove-data-class trivial ?class) ) ) (:method (remove-data-class all-sts ?class) () ( (remove-data-class reorganize-class ?class) ) )
  49. Refactoring Strategy Fragment - Remove DataClass (:method (remove-data-class reorganize-class ?class)

    () ( (remove-data-class move-fe-methods-to-class ?class) (remove-data-class move-client-methods-to-class ?class) (remove-data-class clean-class ?class) ) )
  50. Refactoring Strategy Specification Language strategy remove-feature-envy trivial (method) body apply

    remove-method (method) end strategy remove-feature-envy move-method (method) body alt branch apply remove-feature-envy move-method-to-user-class (method) branch apply remove-feature-envy move-method-to-data-class (method) branch apply remove-feature-envy move-method-to-envied-class (method,env-class) end end strategy remove-feature-envy move-method-to-user-class (method) precondition method-fqn(method, pkg-name, class-name, method-name) user-query("Package name of new class for method", (pkg-name, class-name, method-name), tgt-pkg-name) user-query("Class name of new class for method", (pkg-name, class-name, method-name), tgt-class-name) class-fqn(tgt-class, tgt-pkg-name, tgt-class-name) body apply remove-feature-envy move-method-to-envied-class (method, tgt-class) end strategy remove-feature-envy move-method-to-data-class (method) precondition smell("data class", env-class)
  51. Refactoring Strategy Specification Language strategy remove-feature-envy trivial (method) body apply

    remove-method (method) end strategy remove-feature-envy move-method (method) body alt branch apply remove-feature-envy move-method-to-user-class (method) branch apply remove-feature-envy move-method-to-data-class (method) branch apply remove-feature-envy move-method-to-envied-class (method,env-class) end end strategy remove-feature-envy move-method-to-user-class (method) precondition method-fqn(method, pkg-name, class-name, method-name) user-query("Package name of new class for method", (pkg-name, class-name, method-name), tgt-pkg-name) user-query("Class name of new class for method", (pkg-name, class-name, method-name), tgt-class-name) class-fqn(tgt-class, tgt-pkg-name, tgt-class-name) body apply remove-feature-envy move-method-to-envied-class (method, tgt-class) end strategy remove-feature-envy move-method-to-data-class (method) precondition smell("data class", env-class) user-query("Class name of new class for method", (pkg-name, class-name, method-name), tgt-class-name) class-fqn(tgt-class, tgt-pkg-name, tgt-class-name) body apply remove-feature-envy move-method-to-envied-class (method, tgt-class) end strategy remove-feature-envy move-method-to-data-class (method) precondition smell("data class", env-class) get-envied-class (method, env-class) body apply remove-feature-envy move-method-to-envied-class (method, env-class) end strategy remove-feature-envy move-method-to-envied-class (method, env-class) precondition get-envied-class (method, env-class) get-movemethod-reference (method, env-class, reference) body apply move-method all-sts (method, env-class, reference) end Listing 6.9: Draft of some strategies that may be defined to remove a Feature Envy method.
  52. Refactoring Strategy Specification Language strategy remove-feature-envy trivial (method) body apply

    remove-method (method) end strategy remove-feature-envy move-method (method) body alt branch apply remove-feature-envy move-method-to-user-class (method) branch apply remove-feature-envy move-method-to-data-class (method) branch apply remove-feature-envy move-method-to-envied-class (method,env-class) end end strategy remove-feature-envy move-method-to-user-class (method) precondition method-fqn(method, pkg-name, class-name, method-name) user-query("Package name of new class for method", (pkg-name, class-name, method-name), tgt-pkg-name) user-query("Class name of new class for method", (pkg-name, class-name, method-name), tgt-class-name) class-fqn(tgt-class, tgt-pkg-name, tgt-class-name) body apply remove-feature-envy move-method-to-envied-class (method, tgt-class) end strategy remove-feature-envy move-method-to-data-class (method) precondition smell("data class", env-class) user-query("Class name of new class for method", (pkg-name, class-name, method-name), tgt-class-name) class-fqn(tgt-class, tgt-pkg-name, tgt-class-name) body apply remove-feature-envy move-method-to-envied-class (method, tgt-class) end strategy remove-feature-envy move-method-to-data-class (method) precondition smell("data class", env-class) get-envied-class (method, env-class) body apply remove-feature-envy move-method-to-envied-class (method, env-class) end strategy remove-feature-envy move-method-to-envied-class (method, env-class) precondition get-envied-class (method, env-class) get-movemethod-reference (method, env-class, reference) body apply move-method all-sts (method, env-class, reference) end Listing 6.9: Draft of some strategies that may be defined to remove a Feature Envy method. 138 CHAPTER 6. CASE STUDY strategy move-method all-sts (method, tgt-class, reference) body alt branch apply move-method trivial (method, tgt-class, reference) branch apply move-method basic (method, tgt-class, reference) end end strategy move-method trivial (method, tgt-class, reference) body
  53. Remove Data Class Strategy: example of a plan apply-refactoring:! !

    show-method (org.jwebap.asm.attrs, stackmapattribute, gettypeinfolabels) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, getframelabels, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.attrs, stackmapattribute, writetypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, writeframe, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmify) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, declarelabel) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmifytypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.util.attrs, asmstackmapattribute, asmify, to, org.jwebap.asm.attrs, stackmapframe, through, f keeping-delegate, false) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, label, getlabel, setlabel) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, locals, getlocals, setlocals) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, stack, getstack, setstack) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlabel) (SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlocals)(SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setstack) (SETTER) apply-remove-smell:! remove-data-class (org.jwebap.asm.attrs, stackmapframe) cleanclass
  54. Remove Data Class Strategy: example of a plan apply-refactoring:! !

    show-method (org.jwebap.asm.attrs, stackmapattribute, gettypeinfolabels) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, getframelabels, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.attrs, stackmapattribute, writetypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, writeframe, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmify) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, declarelabel) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmifytypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.util.attrs, asmstackmapattribute, asmify, to, org.jwebap.asm.attrs, stackmapframe, through, f keeping-delegate, false) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, label, getlabel, setlabel) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, locals, getlocals, setlocals) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, stack, getstack, setstack) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlabel) (SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlocals)(SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setstack) (SETTER) apply-remove-smell:! remove-data-class (org.jwebap.asm.attrs, stackmapframe) cleanclass
  55. Remove Data Class Strategy: example of a plan apply-refactoring:! !

    show-method (org.jwebap.asm.attrs, stackmapattribute, gettypeinfolabels) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, getframelabels, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.attrs, stackmapattribute, writetypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, writeframe, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmify) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, declarelabel) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmifytypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.util.attrs, asmstackmapattribute, asmify, to, org.jwebap.asm.attrs, stackmapframe, through, f keeping-delegate, false) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, label, getlabel, setlabel) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, locals, getlocals, setlocals) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, stack, getstack, setstack) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlabel) (SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlocals)(SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setstack) (SETTER) apply-remove-smell:! remove-data-class (org.jwebap.asm.attrs, stackmapframe) cleanclass
  56. Remove Data Class Strategy: example of a plan apply-refactoring:! !

    show-method (org.jwebap.asm.attrs, stackmapattribute, gettypeinfolabels) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, getframelabels, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.attrs, stackmapattribute, writetypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, writeframe, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmify) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, declarelabel) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmifytypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.util.attrs, asmstackmapattribute, asmify, to, org.jwebap.asm.attrs, stackmapframe, through, f keeping-delegate, false) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, label, getlabel, setlabel) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, locals, getlocals, setlocals) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, stack, getstack, setstack) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlabel) (SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlocals)(SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setstack) (SETTER) apply-remove-smell:! remove-data-class (org.jwebap.asm.attrs, stackmapframe) cleanclass
  57. Remove Data Class Strategy: example of a plan apply-refactoring:! !

    show-method (org.jwebap.asm.attrs, stackmapattribute, gettypeinfolabels) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, getframelabels, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.attrs, stackmapattribute, writetypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, writeframe, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmify) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, declarelabel) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmifytypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.util.attrs, asmstackmapattribute, asmify, to, org.jwebap.asm.attrs, stackmapframe, through, f keeping-delegate, false) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, label, getlabel, setlabel) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, locals, getlocals, setlocals) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, stack, getstack, setstack) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlabel) (SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlocals)(SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setstack) (SETTER) apply-remove-smell:! remove-data-class (org.jwebap.asm.attrs, stackmapframe) cleanclass
  58. Remove Data Class Strategy: example of a plan apply-refactoring:! !

    show-method (org.jwebap.asm.attrs, stackmapattribute, gettypeinfolabels) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, getframelabels, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.attrs, stackmapattribute, writetypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, writeframe, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmify) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, declarelabel) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmifytypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.util.attrs, asmstackmapattribute, asmify, to, org.jwebap.asm.attrs, stackmapframe, through, f keeping-delegate, false) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, label, getlabel, setlabel) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, locals, getlocals, setlocals) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, stack, getstack, setstack) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlabel) (SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlocals)(SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setstack) (SETTER) apply-remove-smell:! remove-data-class (org.jwebap.asm.attrs, stackmapframe) cleanclass
  59. Remove Data Class Strategy: example of a plan apply-refactoring:! !

    show-method (org.jwebap.asm.attrs, stackmapattribute, gettypeinfolabels) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, getframelabels, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.attrs, stackmapattribute, writetypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, writeframe, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmify) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, declarelabel) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmifytypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.util.attrs, asmstackmapattribute, asmify, to, org.jwebap.asm.attrs, stackmapframe, through, f keeping-delegate, false) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, label, getlabel, setlabel) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, locals, getlocals, setlocals) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, stack, getstack, setstack) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlabel) (SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlocals)(SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setstack) (SETTER) apply-remove-smell:! remove-data-class (org.jwebap.asm.attrs, stackmapframe) cleanclass
  60. Remove Data Class Strategy: example of a plan apply-refactoring:! !

    show-method (org.jwebap.asm.attrs, stackmapattribute, gettypeinfolabels) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, getframelabels, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.attrs, stackmapattribute, writetypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, writeframe, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmify) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, declarelabel) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmifytypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.util.attrs, asmstackmapattribute, asmify, to, org.jwebap.asm.attrs, stackmapframe, through, f keeping-delegate, false) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, label, getlabel, setlabel) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, locals, getlocals, setlocals) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, stack, getstack, setstack) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlabel) (SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlocals)(SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setstack) (SETTER) apply-remove-smell:! remove-data-class (org.jwebap.asm.attrs, stackmapframe) cleanclass
  61. Remove Data Class Strategy: example of a plan apply-refactoring:! !

    show-method (org.jwebap.asm.attrs, stackmapattribute, gettypeinfolabels) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, getframelabels, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.attrs, stackmapattribute, writetypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, writeframe, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmify) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, declarelabel) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmifytypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.util.attrs, asmstackmapattribute, asmify, to, org.jwebap.asm.attrs, stackmapframe, through, f keeping-delegate, false) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, label, getlabel, setlabel) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, locals, getlocals, setlocals) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, stack, getstack, setstack) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlabel) (SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlocals)(SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setstack) (SETTER) apply-remove-smell:! remove-data-class (org.jwebap.asm.attrs, stackmapframe) cleanclass
  62. Remove Data Class Strategy: example of a plan apply-refactoring:! !

    show-method (org.jwebap.asm.attrs, stackmapattribute, gettypeinfolabels) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, getframelabels, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.attrs, stackmapattribute, writetypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, writeframe, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmify) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, declarelabel) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmifytypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.util.attrs, asmstackmapattribute, asmify, to, org.jwebap.asm.attrs, stackmapframe, through, f keeping-delegate, false) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, label, getlabel, setlabel) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, locals, getlocals, setlocals) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, stack, getstack, setstack) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlabel) (SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlocals)(SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setstack) (SETTER) apply-remove-smell:! remove-data-class (org.jwebap.asm.attrs, stackmapframe) cleanclass
  63. Remove Data Class Strategy: example of a plan apply-refactoring:! !

    show-method (org.jwebap.asm.attrs, stackmapattribute, gettypeinfolabels) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, getframelabels, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.attrs, stackmapattribute, writetypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute, writeframe, to, org.jwebap.asm.attrs, stackmapframe, through, frame, keeping-delegate, false) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmify) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, declarelabel) apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmifytypeinfo) apply-refactoring:! ! move-method (from, org.jwebap.asm.util.attrs, asmstackmapattribute, asmify, to, org.jwebap.asm.attrs, stackmapframe, through, f keeping-delegate, false) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, label, getlabel, setlabel) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, locals, getlocals, setlocals) apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, stack, getstack, setstack) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlabel) (SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlocals)(SETTER) apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setstack) (SETTER) apply-remove-smell:! remove-data-class (org.jwebap.asm.attrs, stackmapframe) cleanclass
  64. Case Study: Feature Envy and Data Class ✤ Independent Variables:

    ✦ PEF: number of program element facts - system size (obtained with JTransformer) ✦ FE: number of Feature Envy design smells (according to iPlasma) ✦ DC: number of Data Class design smells (according to iPlasma) ✤ Dependant Variables: ✦ P: Number of plans obtained for each system ✦ Tp: Planning time (seconds) System Version LOC PEF FE DC 1 Jtombstone 1.1.1 1938 32780 2 7 2 Groom 1.3 3699 35434 2 2 3 Lucene 1.9 17627 85064 18 16 4 Pounder 0.96 9410 98570 26 3 5 MyTelly 1.2 12625 133605 2 13 6 Jwebap 0.6.1 16417 141047 17 21 7 dbXML 2.0 25862 199400 21 40 8 GanttProject 2.0.10 40775 241095 36 24 9 JfreeChart 1.0.11 80668 354543 45 29
  65. Case Study: Feature Envy and Data Class ✤ Independent Variables:

    ✦ PEF: number of program element facts - system size (obtained with JTransformer) ✦ FE: number of Feature Envy design smells (according to iPlasma) ✦ DC: number of Data Class design smells (according to iPlasma) ✤ Dependant Variables: ✦ P: Number of plans obtained for each system ✦ Tp: Planning time (seconds) System Version LOC PEF FE DC 1 Jtombstone 1.1.1 1938 32780 2 7 2 Groom 1.3 3699 35434 2 2 3 Lucene 1.9 17627 85064 18 16 4 Pounder 0.96 9410 98570 26 3 5 MyTelly 1.2 12625 133605 2 13 6 Jwebap 0.6.1 16417 141047 17 21 7 dbXML 2.0 25862 199400 21 40 8 GanttProject 2.0.10 40775 241095 36 24 9 JfreeChart 1.0.11 80668 354543 45 29
  66. Case Study: Feature Envy and Data Class ✤ Independent Variables:

    ✦ PEF: number of program element facts - system size (obtained with JTransformer) ✦ FE: number of Feature Envy design smells (according to iPlasma) ✦ DC: number of Data Class design smells (according to iPlasma) ✤ Dependant Variables: ✦ P: Number of plans obtained for each system ✦ Tp: Planning time (seconds) System Version LOC PEF FE DC 1 Jtombstone 1.1.1 1938 32780 2 7 2 Groom 1.3 3699 35434 2 2 3 Lucene 1.9 17627 85064 18 16 4 Pounder 0.96 9410 98570 26 3 5 MyTelly 1.2 12625 133605 2 13 6 Jwebap 0.6.1 16417 141047 17 21 7 dbXML 2.0 25862 199400 21 40 8 GanttProject 2.0.10 40775 241095 36 24 9 JfreeChart 1.0.11 80668 354543 45 29
  67. Case Study: Feature Envy and Data Class ✤ Independent Variables:

    ✦ PEF: number of program element facts - system size (obtained with JTransformer) ✦ FE: number of Feature Envy design smells (according to iPlasma) ✦ DC: number of Data Class design smells (according to iPlasma) ✤ Dependant Variables: ✦ P: Number of plans obtained for each system ✦ Tp: Planning time (seconds) System Version LOC PEF FE DC 1 Jtombstone 1.1.1 1938 32780 2 7 2 Groom 1.3 3699 35434 2 2 3 Lucene 1.9 17627 85064 18 16 4 Pounder 0.96 9410 98570 26 3 5 MyTelly 1.2 12625 133605 2 13 6 Jwebap 0.6.1 16417 141047 17 21 7 dbXML 2.0 25862 199400 21 40 8 GanttProject 2.0.10 40775 241095 36 24 9 JfreeChart 1.0.11 80668 354543 45 29
  68. Case Study: Feature Envy and Data Class ✤ Independent Variables:

    ✦ PEF: number of program element facts - system size (obtained with JTransformer) ✦ FE: number of Feature Envy design smells (according to iPlasma) ✦ DC: number of Data Class design smells (according to iPlasma) ✤ Dependant Variables: ✦ P: Number of plans obtained for each system ✦ Tp: Planning time (seconds) System Version LOC PEF FE DC 1 Jtombstone 1.1.1 1938 32780 2 7 2 Groom 1.3 3699 35434 2 2 3 Lucene 1.9 17627 85064 18 16 4 Pounder 0.96 9410 98570 26 3 5 MyTelly 1.2 12625 133605 2 13 6 Jwebap 0.6.1 16417 141047 17 21 7 dbXML 2.0 25862 199400 21 40 8 GanttProject 2.0.10 40775 241095 36 24 9 JfreeChart 1.0.11 80668 354543 45 29
  69. Case Study: Feature Envy and Data Class ✤ Independent Variables:

    ✦ PEF: number of program element facts - system size (obtained with JTransformer) ✦ FE: number of Feature Envy design smells (according to iPlasma) ✦ DC: number of Data Class design smells (according to iPlasma) ✤ Dependant Variables: ✦ P: Number of plans obtained for each system ✦ Tp: Planning time (seconds) System Version LOC PEF FE DC 1 Jtombstone 1.1.1 1938 32780 2 7 2 Groom 1.3 3699 35434 2 2 3 Lucene 1.9 17627 85064 18 16 4 Pounder 0.96 9410 98570 26 3 5 MyTelly 1.2 12625 133605 2 13 6 Jwebap 0.6.1 16417 141047 17 21 7 dbXML 2.0 25862 199400 21 40 8 GanttProject 2.0.10 40775 241095 36 24 9 JfreeChart 1.0.11 80668 354543 45 29
  70. Case Study: Feature Envy and Data Class ✤ Independent Variables:

    ✦ PEF: number of program element facts - system size (obtained with JTransformer) ✦ FE: number of Feature Envy design smells (according to iPlasma) ✦ DC: number of Data Class design smells (according to iPlasma) ✤ Dependant Variables: ✦ P: Number of plans obtained for each system ✦ Tp: Planning time (seconds) System Version LOC PEF FE DC 1 Jtombstone 1.1.1 1938 32780 2 7 2 Groom 1.3 3699 35434 2 2 3 Lucene 1.9 17627 85064 18 16 4 Pounder 0.96 9410 98570 26 3 5 MyTelly 1.2 12625 133605 2 13 6 Jwebap 0.6.1 16417 141047 17 21 7 dbXML 2.0 25862 199400 21 40 8 GanttProject 2.0.10 40775 241095 36 24 9 JfreeChart 1.0.11 80668 354543 45 29
  71. Case Study: Feature Envy and Data Class ✤ Independent Variables:

    ✦ PEF: number of program element facts - system size (obtained with JTransformer) ✦ FE: number of Feature Envy design smells (according to iPlasma) ✦ DC: number of Data Class design smells (according to iPlasma) ✤ Dependant Variables: ✦ P: Number of plans obtained for each system ✦ Tp: Planning time (seconds) System Version LOC PEF FE DC 1 Jtombstone 1.1.1 1938 32780 2 7 2 Groom 1.3 3699 35434 2 2 3 Lucene 1.9 17627 85064 18 16 4 Pounder 0.96 9410 98570 26 3 5 MyTelly 1.2 12625 133605 2 13 6 Jwebap 0.6.1 16417 141047 17 21 7 dbXML 2.0 25862 199400 21 40 8 GanttProject 2.0.10 40775 241095 36 24 9 JfreeChart 1.0.11 80668 354543 45 29
  72. Case Study: Feature Envy and Data Class ✤ Independent Variables:

    ✦ PEF: number of program element facts - system size (obtained with JTransformer) ✦ FE: number of Feature Envy design smells (according to iPlasma) ✦ DC: number of Data Class design smells (according to iPlasma) ✤ Dependant Variables: ✦ P: Number of plans obtained for each system ✦ Tp: Planning time (seconds) System Version LOC PEF FE DC 1 Jtombstone 1.1.1 1938 32780 2 7 2 Groom 1.3 3699 35434 2 2 3 Lucene 1.9 17627 85064 18 16 4 Pounder 0.96 9410 98570 26 3 5 MyTelly 1.2 12625 133605 2 13 6 Jwebap 0.6.1 16417 141047 17 21 7 dbXML 2.0 25862 199400 21 40 8 GanttProject 2.0.10 40775 241095 36 24 9 JfreeChart 1.0.11 80668 354543 45 29
  73. Summary of Results Feature Envy Feature Envy Feature Envy Feature

    Envy Feature Envy Feature Envy PEFs Smells Plans % Mean Tp 1 32780 2 1 50 6.49 2 35434 2 1 50 8.98 3 85064 18 3 16.67 10.4 4 98570 26 21 80.77 4.04 5 133605 2 0 0 70.84 6 141047 17 9 52.94 33.98 7 199400 21 11 52.38 109.92 8 241095 36 13 36.11 159.32 9 354543 45 24 53.33 104.71 Totals 169 83 49.11 Data Class Data Class Data Class Data Class Data Class Data Class 1 32780 7 6 85.71 3.78 2 35434 2 2 100 8.93 3 85064 16 16 100 9.48 4 98570 3 3 100 75.63 5 133605 13 11 84.62 20.21 6 141047 21 20 95.24 19.2 7 199400 40 40 100 131.11 8 241095 27 24 88.89 143.62 9 354543 29 23 79.31 61.65 Totals 158 145 91.77 Time is given in seconds.
  74. Summary of Results Feature Envy Feature Envy Feature Envy Feature

    Envy Feature Envy Feature Envy PEFs Smells Plans % Mean Tp 1 32780 2 1 50 6.49 2 35434 2 1 50 8.98 3 85064 18 3 16.67 10.4 4 98570 26 21 80.77 4.04 5 133605 2 0 0 70.84 6 141047 17 9 52.94 33.98 7 199400 21 11 52.38 109.92 8 241095 36 13 36.11 159.32 9 354543 45 24 53.33 104.71 Totals 169 83 49.11 Data Class Data Class Data Class Data Class Data Class Data Class 1 32780 7 6 85.71 3.78 2 35434 2 2 100 8.93 3 85064 16 16 100 9.48 4 98570 3 3 100 75.63 5 133605 13 11 84.62 20.21 6 141047 21 20 95.24 19.2 7 199400 40 40 100 131.11 8 241095 27 24 88.89 143.62 9 354543 29 23 79.31 61.65 Totals 158 145 91.77 Time is given in seconds.
  75. Summary of Results Feature Envy Feature Envy Feature Envy Feature

    Envy Feature Envy Feature Envy PEFs Smells Plans % Mean Tp 1 32780 2 1 50 6.49 2 35434 2 1 50 8.98 3 85064 18 3 16.67 10.4 4 98570 26 21 80.77 4.04 5 133605 2 0 0 70.84 6 141047 17 9 52.94 33.98 7 199400 21 11 52.38 109.92 8 241095 36 13 36.11 159.32 9 354543 45 24 53.33 104.71 Totals 169 83 49.11 Data Class Data Class Data Class Data Class Data Class Data Class 1 32780 7 6 85.71 3.78 2 35434 2 2 100 8.93 3 85064 16 16 100 9.48 4 98570 3 3 100 75.63 5 133605 13 11 84.62 20.21 6 141047 21 20 95.24 19.2 7 199400 40 40 100 131.11 8 241095 27 24 88.89 143.62 9 354543 29 23 79.31 61.65 Totals 158 145 91.77 Time is given in seconds.
  76. Summary of Results Feature Envy Feature Envy Feature Envy Feature

    Envy Feature Envy Feature Envy PEFs Smells Plans % Mean Tp 1 32780 2 1 50 6.49 2 35434 2 1 50 8.98 3 85064 18 3 16.67 10.4 4 98570 26 21 80.77 4.04 5 133605 2 0 0 70.84 6 141047 17 9 52.94 33.98 7 199400 21 11 52.38 109.92 8 241095 36 13 36.11 159.32 9 354543 45 24 53.33 104.71 Totals 169 83 49.11 Data Class Data Class Data Class Data Class Data Class Data Class 1 32780 7 6 85.71 3.78 2 35434 2 2 100 8.93 3 85064 16 16 100 9.48 4 98570 3 3 100 75.63 5 133605 13 11 84.62 20.21 6 141047 21 20 95.24 19.2 7 199400 40 40 100 131.11 8 241095 27 24 88.89 143.62 9 354543 29 23 79.31 61.65 Totals 158 145 91.77 Time is given in seconds.
  77. Summary of Results Feature Envy Feature Envy Feature Envy Feature

    Envy Feature Envy Feature Envy PEFs Smells Plans % Mean Tp 1 32780 2 1 50 6.49 2 35434 2 1 50 8.98 3 85064 18 3 16.67 10.4 4 98570 26 21 80.77 4.04 5 133605 2 0 0 70.84 6 141047 17 9 52.94 33.98 7 199400 21 11 52.38 109.92 8 241095 36 13 36.11 159.32 9 354543 45 24 53.33 104.71 Totals 169 83 49.11 Data Class Data Class Data Class Data Class Data Class Data Class 1 32780 7 6 85.71 3.78 2 35434 2 2 100 8.93 3 85064 16 16 100 9.48 4 98570 3 3 100 75.63 5 133605 13 11 84.62 20.21 6 141047 21 20 95.24 19.2 7 199400 40 40 100 131.11 8 241095 27 24 88.89 143.62 9 354543 29 23 79.31 61.65 Totals 158 145 91.77 Time is given in seconds.
  78. Summary of Results Feature Envy Feature Envy Feature Envy Feature

    Envy Feature Envy Feature Envy PEFs Smells Plans % Mean Tp 1 32780 2 1 50 6.49 2 35434 2 1 50 8.98 3 85064 18 3 16.67 10.4 4 98570 26 21 80.77 4.04 5 133605 2 0 0 70.84 6 141047 17 9 52.94 33.98 7 199400 21 11 52.38 109.92 8 241095 36 13 36.11 159.32 9 354543 45 24 53.33 104.71 Totals 169 83 49.11 Data Class Data Class Data Class Data Class Data Class Data Class 1 32780 7 6 85.71 3.78 2 35434 2 2 100 8.93 3 85064 16 16 100 9.48 4 98570 3 3 100 75.63 5 133605 13 11 84.62 20.21 6 141047 21 20 95.24 19.2 7 199400 40 40 100 131.11 8 241095 27 24 88.89 143.62 9 354543 29 23 79.31 61.65 Totals 158 145 91.77 Time is given in seconds.
  79. Summary of Results Feature Envy Feature Envy Feature Envy Feature

    Envy Feature Envy Feature Envy PEFs Smells Plans % Mean Tp 1 32780 2 1 50 6.49 2 35434 2 1 50 8.98 3 85064 18 3 16.67 10.4 4 98570 26 21 80.77 4.04 5 133605 2 0 0 70.84 6 141047 17 9 52.94 33.98 7 199400 21 11 52.38 109.92 8 241095 36 13 36.11 159.32 9 354543 45 24 53.33 104.71 Totals 169 83 49.11 Data Class Data Class Data Class Data Class Data Class Data Class 1 32780 7 6 85.71 3.78 2 35434 2 2 100 8.93 3 85064 16 16 100 9.48 4 98570 3 3 100 75.63 5 133605 13 11 84.62 20.21 6 141047 21 20 95.24 19.2 7 199400 40 40 100 131.11 8 241095 27 24 88.89 143.62 9 354543 29 23 79.31 61.65 Totals 158 145 91.77 Time is given in seconds.
  80. 0 50000 100000 150000 200000 250000 300000 350000 400000 0

    120 240 360 480 600 720 840 960 1080 1200 1320 1440 1560 Mean Planning Time Std. Deviation 0.75 0.90 Factbase Size Feature Envy Planning Time (secs.) Probabilistic Upper Bounds for Planning Time ✦ Upper bounds for Tp computed with Chebishev’s Inequality for 75% and 90% probability 0 50000 100000 150000 200000 250000 300000 350000 400000 0 120 240 360 480 600 720 840 960 1080 1200 1320 1440 Factbase Size Data Class Planning Time (secs.)
  81. 0 50000 100000 150000 200000 250000 300000 350000 400000 0

    120 240 360 480 600 720 840 960 1080 1200 1320 1440 1560 Mean Planning Time Std. Deviation 0.75 0.90 Factbase Size Feature Envy Planning Time (secs.) Probabilistic Upper Bounds for Planning Time ✦ Upper bounds for Tp computed with Chebishev’s Inequality for 75% and 90% probability 0 50000 100000 150000 200000 250000 300000 350000 400000 0 120 240 360 480 600 720 840 960 1080 1200 1320 1440 Factbase Size Data Class Planning Time (secs.) 200,000 PEF 26,000 LOC 90% cases < 16 min. 75% cases < 11 min.
  82. Experiment Conclusions ✤ Effectiveness: ✦ 50% plans for Feature Envy

    and 92% for Data Class ✤ Efficiency and scalability (analysis): ✦ Planning time is very disperse. ✦ Planning time does not follow a normal distribution. ✦ Planning time depends on system size. ✦ Results for the dependency between planning time and strategies are not conclusive. ✦ Probabilistic upper bounds of planning time are satisfactory. ✤ Efficiency and scalability (conclusions): ✦ Planning time is reasonable for a prototype. ✦ Scalability is hard to infer, good for the tested sizes, promising results.
  83. Future Work ✤ Improve the refactoring planning domain ✦ More

    atomic refactoring specifications ✦ More complex refactoring strategies ✦ More smells correction strategies ✤ Improve the prototype ✦ Better integration ✦ Eclipse plugin - refactoring specifications needed for straight execution ✦ Refactoring strategy editor ✤ Explore different application scenarios for the approach ✦ design patterns ✦ refactoring development and debugging
  84. Limitations ✤ Dependency on the refactoring planning domain - the

    implemented domain knowledge ✤ The lack of documented specifications of refactoring implementations does not permit straight execution of plans ✤ HTN planning searches a severely pruned search space -restricted to the specified knowledge networks ✤ Designed to plan for a single refactoring strategy at a time
  85. Similarities with other approaches shown today ✦ There is a

    need to implement big refactorings ✦ Big refactorings implemented “empirically” - with recipes ✦ Usage of a DSL to allow the developer describe refactoring recipes ✦ The need for refactoring and recipes composition ✦ The need for refactoring and recipes analysis - instantiation
  86. More information “Refactoring Planning for Design Smell Correction in Object-Oriented

    Ssoftware” Javier Pérez; PhD Thesis, July 2011, University of Valladolid Supervised by Dr. Yania Crespo
  87. Computation of Refactoring Plans from Refactoring Strategies using HTN Planning

    WRT2012 June 1st - Rapperswil, Switzerland Javier Pérez Université de Mons, Belgium [email protected] Yania Crespo Universidad de Valladolid, Spain [email protected]