Slide 1

Slide 1 text

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]

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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)

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

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 )

Slide 39

Slide 39 text

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)

Slide 40

Slide 40 text

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)

Slide 41

Slide 41 text

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)

Slide 42

Slide 42 text

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)

Slide 43

Slide 43 text

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)

Slide 44

Slide 44 text

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)

Slide 45

Slide 45 text

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)

Slide 46

Slide 46 text

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)

Slide 47

Slide 47 text

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)

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

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

Slide 50

Slide 50 text

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)

Slide 51

Slide 51 text

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.

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

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

Slide 56

Slide 56 text

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

Slide 57

Slide 57 text

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

Slide 58

Slide 58 text

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

Slide 59

Slide 59 text

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

Slide 60

Slide 60 text

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

Slide 61

Slide 61 text

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

Slide 62

Slide 62 text

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

Slide 63

Slide 63 text

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

Slide 64

Slide 64 text

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

Slide 65

Slide 65 text

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

Slide 66

Slide 66 text

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

Slide 67

Slide 67 text

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

Slide 68

Slide 68 text

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

Slide 69

Slide 69 text

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

Slide 70

Slide 70 text

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

Slide 71

Slide 71 text

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

Slide 72

Slide 72 text

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

Slide 73

Slide 73 text

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.

Slide 74

Slide 74 text

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.

Slide 75

Slide 75 text

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.

Slide 76

Slide 76 text

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.

Slide 77

Slide 77 text

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.

Slide 78

Slide 78 text

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.

Slide 79

Slide 79 text

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.

Slide 80

Slide 80 text

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

Slide 81

Slide 81 text

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.

Slide 82

Slide 82 text

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.

Slide 83

Slide 83 text

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

Slide 84

Slide 84 text

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

Slide 85

Slide 85 text

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

Slide 86

Slide 86 text

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

Slide 87

Slide 87 text

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]