scispace - formally typeset
Search or ask a question
Proceedings ArticleDOI

Refactoring opportunities for replacing type code with state and subclass

TL;DR: There islevance of two popular refactorings "Replace Type Code withSubclass" and " replace Type code with State" in real world Java applications and some of the challenges in automatically identifying these refactoring opportunities are described.
Abstract: Refactoring restructures a program to improve its readability and maintainability, without changing its original behavior. One of the key steps in refactoring is the identification of potential refactoring opportunities. In this paper, we discuss the relevance of two popular refactorings "Replace Type Code with Subclass" and "Replace Type Code with State" in real world Java applications and describe some of the challenges in automatically identifying these refactoring opportunities.
Citations
More filters
Journal ArticleDOI
TL;DR: In this article, the authors present a tertiary systematic literature review of previous surveys, secondary systematic literature reviews, and systematic mappings on code smells and refactoring, and identify the main observations (what we know) and challenges (What we do not know) on code smell and reusability.

65 citations

Proceedings ArticleDOI
10 Nov 2019
TL;DR: A batch alias analysis framework is presented that can be used to speed up given demand-driven alias analysis, and it is shown that batch analysis leads to significant performance gains, along with minor gains in precision.
Abstract: Many program-analysis based tools require precise points-to/alias information only for some program variables. To meet this requirement efficiently, there have been many works on demand-driven analyses that perform only the work necessary to compute the points-to or alias information on the requested variables (queries). However, these demand-driven analyses can be very expensive when applied on large systems where the number of queries can be significant. Such a blow-up in analysis time is unacceptable in cases where scalability with real-time constraints is crucial; for example, when program analysis tools are plugged into an IDE (Integrated Development Environment). In this paper, we propose schemes to improve the scalability of demand-driven analyses without compromising on precision. Our work is based on novel ideas for eliminating irrelevant and redundant data-flow paths for the given queries. We introduce the idea of batch analysis, which can answer multiple given queries in batch mode. Batch analysis suits the environments with strict time constraints, where the queries come in batch. We present a batch alias analysis framework that can be used to speed up given demand-driven alias analysis. To show the effectiveness of this framework, we use two demand-driven alias analyses (1) the existing best performing demand-driven alias analysis tool for race-detection clients and (2) an optimized version thereof that avoids irrelevant computation. Our evaluations on a simulated data-race client, and on a recent program-understanding tool, show that batch analysis leads to significant performance gains, along with minor gains in precision.

10 citations


Cites methods from "Refactoring opportunities for repla..."

  • ...For Auto-SCST, we use the eight open-source applications used by Vedurada and Nandivada [5], [29]....

    [...]

Journal ArticleDOI
TL;DR: In this article, the authors present a tertiary systematic literature review of previous surveys, secondary systematic literature reviews, and systematic mappings on code smells and refactoring, and identify the main observations (what we know) and challenges (What we do not know) on code smell and reusability.
Abstract: In this paper, we present a tertiary systematic literature review of previous surveys, secondary systematic literature reviews, and systematic mappings. We identify the main observations (what we know) and challenges (what we do not know) on code smells and refactoring. We show that code smells and refactoring have a strong relationship with quality attributes, i.e., with understandability, maintainability, testability, complexity, functionality, and reusability. We argue that code smells and refactoring could be considered as the two faces of a same coin. Besides, we identify how refactoring affects quality attributes, more than code smells. We also discuss the implications of this work for practitioners, researchers, and instructors. We identify 13 open issues that could guide future research work. Thus, we want to highlight the gap between code smells and refactoring in the current state of software-engineering research. We wish that this work could help the software-engineering research community in collaborating on future work on code smells and refactoring.

8 citations

Journal ArticleDOI
13 Sep 2018
TL;DR: The complete re- engineering process with aspects of forwarding, reverse and quality assurance mechanism is discussed and a methodological approach to move from re-engineering to the journey of quality assurance is discussed.
Abstract: Software development advances focus on productivity of existing software systems and quality is the basic demand of every engineering product. In this paper, we will discuss the complete re-engineering process with aspects of forwarding, reverse and quality assurance mechanism. As we know the software development lifecycle (SDLC) follows a complete mechanism of the engineering process. In forward engineering, we tried to follow selective main phases of software engineering(data,requirements, design, development, implementation).In reverse engineering, we move backward from the last phase of developing the product as it gathers requirements from the implemented product(implementation, coding, design, requirements, data). During reengineering, we add up more quality features on customer demands, but the actual demand is to fulfill quality needs that can be assured by external as well as internal quality attributes such as reliability, efficiency, flexibility, reusability, and robustness in any software system. We discussed a methodological approach to move from re-engineering to the journey of quality assurance. More than 50 studies come into discussion and throughput results proposed by graph and tabular form. We can say if the re-engineering process produces quality attributes, then it can be said by old software system refactoring as code refactoring, data refactoring and architectural refactoring we obtained a quality product at a lower cost instead of new software system development, which causes a decrease in quality attributes as cost, time etc. In future work, testing methodology can be proposed for quality assurance.

4 citations

Journal ArticleDOI
24 Oct 2018
TL;DR: This paper presents a formal definition of control-fields and presents algorithms to identify and prune them, and presents a novel flow- and context-sensitive analysis to classify each of these refactoring opportunities into one of the SC and ST opportunities.
Abstract: Refactoring is a program transformation that restructures existing code without altering its behaviour and is a key practice in popular software design movements, such as Agile. Identification of potential refactoring opportunities is an important step in the refactoring process. In large systems, manual identification of useful refactoring opportunities requires a lot of effort and time. Hence, there is a need for automatic identification of refactoring opportunities. However, this problem has not been addressed well for many non-trivial refactorings. Two such non-trivial, yet popular refactorings are “Replace Type Code with Subclass” (SC) and “Replace Type Code with State” (ST) refactorings. In this paper, we present new approaches to identify SC and ST refactoring opportunities. Our proposed approach is based around the notion of control-fields. A control-field is a field of a class that exposes the different underlying behaviors of the class. Each control-field can lead to a possible SC/ST refactoring of the associated/interacting classes. We first present a formal definition of control-fields and then present algorithms to identify and prune them; each of these pruned control-fields represents a refactoring opportunity. Further, we present a novel flow- and context-sensitive analysis to classify each of these refactoring opportunities into one of the SC and ST opportunities. We have implemented our proposed approach in a tool called Auto-SCST, and demonstrated its effectiveness by evaluating it against eight open-source Java applications.

3 citations


Cites background or methods from "Refactoring opportunities for repla..."

  • ...There are two important challenges in this step as discussed in a recent work [Vedurada and Nandivada 2017]: (i) In large code bases, like jfreechart (513 classes) and avrora (1,746 classes), identifying SC/ST refactoring opportunities, manually or via scripts [Kim et al. 2015], is a non-trivial…...

    [...]

  • ...Effective RCP refactoring depends on systematically performing two important [Vedurada and Nandivada 2017] refactorings to build the required class hierarchy: i) replace type code with subclasses (SC), and ii) replace type code with state (ST)1....

    [...]

  • ...A popular and highly recommended way [Kannangara and Wijayanayake 2014] to refactor code with conditional-state-checking statements (like the ones discussed above) is by using the łReplace Conditional with Polymorphismž (RCP) refactoring [Fowler 1999; Opdyke 1992; Vedurada and Nandivada 2017]....

    [...]

References
More filters
Book
Martin Fowler1
01 Jan 1999
TL;DR: Almost every expert in Object-Oriented Development stresses the importance of iterative development, but how do you add function to the existing code base while still preserving its design integrity?
Abstract: Almost every expert in Object-Oriented Development stresses the importance of iterative development. As you proceed with the iterative development, you need to add function to the existing code base. If you are really lucky that code base is structured just right to support the new function while still preserving its design integrity. Of course most of the time we are not lucky, the code does not quite fit what we want to do. You could just add the function on top of the code base. But soon this leads to applying patch upon patch making your system more complex than it needs to be. This complexity leads to bugs, and cripples your productivity.

5,174 citations

Proceedings ArticleDOI
01 Nov 2017
TL;DR: The present document details the how, why and when to apply refactoring in computer systems that have been poorly designed, this in order to a better performance and maintenance of the constituent components.
Abstract: The present document contains the most relevant results obtained in the study of refactoring Mainly it addresses the general aspects of refactoring and the basic concepts that make it up, then it details the how, why and when to apply refactoring in computer systems that have been poorly designed, this in order to a better performance and maintenance of the constituent components Finally, it is emphasized the importance of the refactoring process as such in software development

1,676 citations


"Refactoring opportunities for repla..." refers background or methods in this paper

  • ...Kannangara and Wijayanayake [3] also empirically show that RCP refactoring is the most effective refactoring (among the ones listed the Fowlers catalog [2]) to improve the code....

    [...]

  • ...This state-checking code can be seen as an SC/ST refactoring opportunity and can be improved by applying SC/ST refactoring followed by RCP refactoring [2]; Fig....

    [...]

  • ...Choosing the best suited refactoring between SC and ST requires checking whether the typecode is mutable [2]....

    [...]

  • ...The code with complex conditional-state-checking statements can be improved by using “replace conditional with polymorphism” (RCP) refactoring [1], [2]....

    [...]

  • ...The first complexity in identifying refactoring opportunities is to identify the possible list of type codes [2]....

    [...]

Proceedings ArticleDOI
16 Oct 2006
TL;DR: This paper recommends benchmarking selection and evaluation methodologies, and introduces the DaCapo benchmarks, a set of open source, client-side Java benchmarks that improve over SPEC Java in a variety of ways, including more complex code, richer object behaviors, and more demanding memory system requirements.
Abstract: Since benchmarks drive computer science research and industry product development, which ones we use and how we evaluate them are key questions for the community. Despite complex runtime tradeoffs due to dynamic compilation and garbage collection required for Java programs, many evaluations still use methodologies developed for C, C++, and Fortran. SPEC, the dominant purveyor of benchmarks, compounded this problem by institutionalizing these methodologies for their Java benchmark suite. This paper recommends benchmarking selection and evaluation methodologies, and introduces the DaCapo benchmarks, a set of open source, client-side Java benchmarks. We demonstrate that the complex interactions of (1) architecture, (2) compiler, (3) virtual machine, (4) memory management, and (5) application require more extensive evaluation than C, C++, and Fortran which stress (4) much less, and do not require (3). We use and introduce new value, time-series, and statistical metrics for static and dynamic properties such as code complexity, code size, heap composition, and pointer mutations. No benchmark suite is definitive, but these metrics show that DaCapo improves over SPEC Java in a variety of ways, including more complex code, richer object behaviors, and more demanding memory system requirements. This paper takes a step towards improving methodologies for choosing and evaluating benchmarks to foster innovation in system design and implementation for Java and other managed languages.

1,561 citations


"Refactoring opportunities for repla..." refers background in this paper

  • ...2 are taken from the DaCapo [7] benchmark suite; these projects are stable releases....

    [...]

  • ...07.2 are taken from the DaCapo [7] benchmark suite; these projects are stable releases....

    [...]

01 Jan 1992
TL;DR: This thesis gives some conservative algorithms for determining whether a program satisfies constraints, and describes how to use this design information to refactor a program.
Abstract: This thesis defines a set of program restructuring operations (refactorings) that support the design, evolution and reuse of object-oriented application frameworks. The focus of the thesis is on automating the refactorings in a way that preserves the behavior of a program. The refactorings are defined to be behavior preserving, provided that their preconditions are met. Most of the refactorings are simple to implement and it is almost trivial to show that they are behavior preserving. However, for a few refactorings, one or more of their preconditions are in general undecidable. Fortunately, for some cases it can be determined whether these refactorings can be applied safely. Three of the most complex refactorings are defined in detail: generalizing the inheritance hierarchy, specializing the inheritance hierarchy and using aggregations to model the relationships among classes. These operations are decomposed into more primitive parts, and the power of these operations is discussed from the perspectives of automatability and usefulness in supporting design. Two design constraints needed in refactoring are class invariants and exclusive components. These constraints are needed to ensure that behavior is preserved across some refactorings. This thesis gives some conservative algorithms for determining whether a program satisfies these constraints, and describes how to use this design information to refactor a program.

1,193 citations


"Refactoring opportunities for repla..." refers methods in this paper

  • ...The code with complex conditional-state-checking statements can be improved by using “replace conditional with polymorphism” (RCP) refactoring [1], [2]....

    [...]

Journal ArticleDOI
TL;DR: This paper proposes a technique that extracts refactoring suggestions introducing polymorphism and ensures the behavior preservation of the code and the applicability of the refactored suggestions based on the examination of a set of preconditions.

52 citations


"Refactoring opportunities for repla..." refers background in this paper

  • ...Recent works [5], [6] aim to automatically identify such opportunities....

    [...]