Supporting single responsibility through automated extract method
refactoring
- URL: http://arxiv.org/abs/2305.03428v2
- Date: Sun, 26 Nov 2023 08:42:12 GMT
- Title: Supporting single responsibility through automated extract method
refactoring
- Authors: Alireza Ardalani, Saeed Parsa, Morteza Zakeri-Nasrabadi, Alexander
Chatzigeorgiou
- Abstract summary: We propose a backward slicing algorithm to decompose a long method into slightly overlapping slices.
The slices are computed for each output instruction, representing the outcome of a responsibility delegated to the method.
On average, our experiments demonstrate at least a 29.6% improvement in precision and a 12.1% improvement in the recall of uncovering opportunities.
- Score: 48.0838443679187
- License: http://creativecommons.org/licenses/by/4.0/
- Abstract: The responsibility of a method/function is to perform some desired
computations and disseminate the results to its caller through various
deliverables, including object fields and variables in output instructions.
Based on this definition of responsibility, this paper offers a new algorithm
to refactor long methods to those with a single responsibility. We propose a
backward slicing algorithm to decompose a long method into slightly overlapping
slices. The slices are computed for each output instruction, representing the
outcome of a responsibility delegated to the method. The slices will be
non-overlapping if the slicing criteria address the same output variable. The
slices are further extracted as independent methods, invoked by the original
method if certain behavioral preservations are made. The proposed method has
been evaluated on the GEMS extract method refactoring benchmark and three
real-world projects. On average, our experiments demonstrate at least a 29.6%
improvement in precision and a 12.1% improvement in the recall of uncovering
refactoring opportunities compared to the state-of-the-art approaches.
Furthermore, our tool improves method-level cohesion metrics by an average of
20% after refactoring. Experimental results confirm the applicability of the
proposed approach in extracting methods with a single responsibility.
Related papers
- Context-Enhanced LLM-Based Framework for Automatic Test Refactoring [10.847400457238423]
Test smells arise from poor design practices and insufficient domain knowledge.
We propose UTRefactor, a context-enhanced, LLM-based framework for automatic test in Java projects.
We evaluate UTRefactor on 879 tests from six open-source Java projects, reducing the number of test smells from 2,375 to 265, achieving an 89% reduction.
arXiv Detail & Related papers (2024-09-25T08:42:29Z) - Domain Generalization via Rationale Invariance [70.32415695574555]
This paper offers a new perspective to ease the challenge of domain generalization, which involves maintaining robust results even in unseen environments.
We propose treating the element-wise contributions to the final results as the rationale for making a decision and representing the rationale for each sample as a matrix.
Our experiments demonstrate that the proposed approach achieves competitive results across various datasets, despite its simplicity.
arXiv Detail & Related papers (2023-08-22T03:31:40Z) - TreeDQN: Learning to minimize Branch-and-Bound tree [78.52895577861327]
Branch-and-Bound is a convenient approach to solving optimization tasks in the form of Mixed Linear Programs.
The efficiency of the solver depends on the branchning used to select a variable for splitting.
We propose a reinforcement learning method that can efficiently learn the branching.
arXiv Detail & Related papers (2023-06-09T14:01:26Z) - Calibrated Multiple-Output Quantile Regression with Representation
Learning [12.826754199680472]
We use a deep generative model to learn a representation of a response with a unimodal distribution.
We then transform the solution to the original space of the response.
Experiments conducted on both real and synthetic data show that our method constructs regions that are significantly smaller.
arXiv Detail & Related papers (2021-10-02T14:50:15Z) - A Boosting Approach to Reinforcement Learning [59.46285581748018]
We study efficient algorithms for reinforcement learning in decision processes whose complexity is independent of the number of states.
We give an efficient algorithm that is capable of improving the accuracy of such weak learning methods.
arXiv Detail & Related papers (2021-08-22T16:00:45Z) - Provable Benefits of Actor-Critic Methods for Offline Reinforcement
Learning [85.50033812217254]
Actor-critic methods are widely used in offline reinforcement learning practice, but are not so well-understood theoretically.
We propose a new offline actor-critic algorithm that naturally incorporates the pessimism principle.
arXiv Detail & Related papers (2021-08-19T17:27:29Z) - A concise method for feature selection via normalized frequencies [0.0]
In this paper, a concise method is proposed for universal feature selection.
The proposed method uses a fusion of the filter method and the wrapper method, rather than a combination of them.
The evaluation results show that the proposed method outperformed several state-of-the-art related works in terms of accuracy, precision, recall, F-score and AUC.
arXiv Detail & Related papers (2021-06-10T15:29:54Z) - Variable Instance-Level Explainability for Text Classification [9.147707153504117]
We propose a method for extracting variable-length explanations using a set of different feature scoring methods at instance-level.
Our method consistently provides more faithful explanations compared to previous fixed-length and fixed-feature scoring methods for rationale extraction.
arXiv Detail & Related papers (2021-04-16T16:53:48Z) - DiffPrune: Neural Network Pruning with Deterministic Approximate Binary
Gates and $L_0$ Regularization [0.0]
Modern neural network architectures typically have many millions of parameters and can be pruned significantly without substantial loss in effectiveness.
The contribution of this work is two-fold.
The first is a method for approximating a multivariate Bernoulli random variable by means of a deterministic and differentiable transformation of any real-valued random variable.
The second is a method for model selection by element-wise parameters with approximate binary gates that may be computed deterministically or multiplicationally and take on exact zero values.
arXiv Detail & Related papers (2020-12-07T13:08:56Z) - Fast Template Matching and Update for Video Object Tracking and
Segmentation [56.465510428878]
The main task we aim to tackle is the multi-instance semi-supervised video object segmentation across a sequence of frames.
The challenges lie in the selection of the matching method to predict the result as well as to decide whether to update the target template.
We propose a novel approach which utilizes reinforcement learning to make these two decisions at the same time.
arXiv Detail & Related papers (2020-04-16T08:58:45Z)
This list is automatically generated from the titles and abstracts of the papers in this site.
This site does not guarantee the quality of this site (including all information) and is not responsible for any consequences.