The work of decomposing long methods into smaller ones is commonly assisted by the Extract Method refactoring technique. However, local variable usages can make code extraction difficult. Therefore, Replace Method with Method Object refactoring technique lets the developer create a field for each variable, and then code extractions can be performed without worrying about variable dependences. However, this can lead to classes having many fields used by a few of its methods. Moreover, the considered fields may not correctly describe the actual object state, making the class harder to understand. This paper proposes a data dependence analysis approach for guiding the Replace Method with Method Object refactoring technique, with the aim of reducing the set of variables becoming fields while properly handling data dependence. The resulting class is easier to understand, having less fields holding the state, while using local variables and parameters to confine all the other data dependence details.
|Titolo:||Assisting Replace Method with Method Object: Selecting Fields and Preserving Data Access|
|Data di pubblicazione:||2018|
|Appare nelle tipologie:||4.1 Contributo in Atti di convegno|