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.
Supplemental Material
- Gabriele Bavota, Andrea Lucia, Andrian Marcus, and Rocco Oliveto. 2014. Automating Extract Class Refactoring: An Improved Method and Its Evaluation. Empirical Softw. Engg. 19, 6 (Dec. 2014), 1617–1664. Google Scholar
Digital Library
- S. M. Blackburn, R. Garner, C. Hoffman, A. M. Khan, K. S. McKinley, R. Bentzur, A. Diwan, D. Feinberg, D. Frampton, S. Z. Guyer, M. Hirzel, A. Hosking, M. Jump, H. Lee, J. E. B. Moss, A. Phansalkar, D. Stefanović, T. VanDrunen, D. von Dincklage, and B. Wiedermann. 2006. The DaCapo Benchmarks: Java Benchmarking Development and Analysis. In OOPSLA ’06 . ACM Press, New York, NY, USA, 169–190. Google Scholar
Digital Library
- Ramkrishna Chatterjee, Barbara G. Ryder, and William A. Landi. 1999. Relevant Context Inference. In Proceedings of the 26th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’99) . ACM, New York, NY, USA, 133–146. Google Scholar
Digital Library
- Aikaterini Christopoulou, E. A. Giakoumakis, Vassilis E. Zafeiris, and Vasiliki Soukara. 2012. Automated Refactoring to the Strategy Design Pattern. Inf. Softw. Technol. 54, 11 (Nov. 2012), 1202–1214. Google Scholar
Digital Library
- Jeffrey Dean, David Grove, and Craig Chambers. 1995. Optimization of Object-Oriented Programs Using Static Class Hierarchy Analysis. In Proceedings of the 9th European Conference on Object-Oriented Programming (ECOOP ’95). SpringerVerlag, London, UK, UK, 77–101. http://dl.acm.org/citation.cfm?id=646153.679523 Google Scholar
Digital Library
- Serge Demeyer, Stéphane Ducasse, and Oscar Nierstrasz. 2002. Object-oriented reengineering patterns. Elsevier. Google Scholar
Digital Library
- Eclipse. 2017. Eclipse: A Java Integrated Development Environment (IDE). https://eclipse.org/Google Scholar
- M. Fowler. 1999. Refactoring: Improving the Design of Existing Code. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA. Google Scholar
Digital Library
- Maria Anna G. Gaitani, Vassilis E. Zafeiris, N.A. Diamantidis, and E.A. Giakoumakis. 2015. Automated Refactoring to the Null Object Design Pattern. Inf. Softw. Technol. 59, C (March 2015), 33–52. Google Scholar
Digital Library
- William H. Harrison. 1977. Compiler Analysis of the Value Ranges for Variables. IEEE Transactions on Software Engineering SE-13, 3 (May 1977). Google Scholar
Digital Library
- C. Jebelean, C.B. Chirila, and V Cretu. 2010. A logic based approach to locate composite refactoring opportunities in object-oriented code. In Automation Quality and Testing Robotics. IEEE, 1–6. Google Scholar
Digital Library
- Sang-Uk Jeon, Joon-Sang Lee, and Doo-Hwan Bae. 2002. An Automated Refactoring Approach to Design Pattern-Based Program Transformations in Java Programs. In Proceedings of the Ninth Asia-Pacific Software Engineering Conference (APSEC ’02) . IEEE Computer Society, Washington, DC, USA, 337–. http://dl.acm.org/citation.cfm?id=785409.785835 Google Scholar
Digital Library
- Sandeepa Harshanganie Kannangara and Janaka Wijayanayake. 2014. An Empirical Exploration of Refactoring effect on Software Quality using External Quality Factors. The International Journal on Advances in ICT for Emerging Regions (ICTer) 7, 2 (2014).Google Scholar
Cross Ref
- Yoshio Kataoka, David Notkin, Michael D Ernst, and William G Griswold. 2001. Automated support for program refactoring using invariants. In Proceedings of the IEEE International Conference on Software Maintenance (ICSM’01). IEEE Computer Society, 736. Google Scholar
Digital Library
- Joshua Kerievsky. 2005. Refactoring to patterns. Pearson Deutschland GmbH. Google Scholar
Digital Library
- Jongwook Kim, Don Batory, and Danny Dig. 2015. Scripting Parametric Refactorings in Java to Retrofit Design Patterns. In Proceedings of the 2015 IEEE International Conference on Software Maintenance and Evolution (ICSME) (ICSME ’15) . IEEE Computer Society, Washington, DC, USA, 211–220. Google Scholar
Digital Library
- Raghavan Komondoor, V. Krishna Nandivada, Saurabh Sinha, and John Field. 2012. Identifying Services from Legacy Batch Applications. In Proceedings of the 5th India Software Engineering Conference (ISEC ’12). ACM, New York, NY, USA, 13–22. Google Scholar
Digital Library
- Raghavan Komondoor and G. Ramalingam. 2007. Recovering Data Models via Guarded Dependences. In Proceedings of the 14th Working Conference on Reverse Engineering (WCRE ’07) . IEEE Computer Society, Washington, DC, USA, 110–119. Google Scholar
Digital Library
- Ondřej Lhoták and Laurie Hendren. 2003. Scaling Java Points-to Analysis Using Spark. In Compiler Construction, Görel Hedin (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 153–169. Google Scholar
Digital Library
- T. J. McCabe. 1976. A Complexity Measure. IEEE Trans. Softw. Eng. 2, 4 (July 1976), 308–320. Google Scholar
Digital Library
- William F. Opdyke. 1992. Refactoring Object-oriented Frameworks. Ph.D. Dissertation. University of Illinois at UrbanaChampaign, Champaign, IL, USA. UMI Order No. GAX93-05645. Google Scholar
Digital Library
- William F. Opdyke and Ralph E. Johnson. 1993. Creating Abstract Superclasses by Refactoring. In Proceedings of the 1993 ACM Conference on Computer Science (CSC ’93) . ACM, New York, NY, USA, 66–73. Google Scholar
Digital Library
- Alexandru D. Salcianu. 2006. Pointer Analysis for Java Programs: Novel Techniques and Applications. Ph.D. Dissertation. Cambridge, MA, USA. Advisor(s) Rinard, Martin C. AAI0818179. Google Scholar
Digital Library
- Sourceforge. 2016. SoureForge. https://sourceforge.net/Google Scholar
- Johannes Späth, Lisa Nguyen Quang Do, Karim Ali, and Eric Bodden. 2016. Boomerang: Demand-Driven Flow- and Context-Sensitive Pointer Analysis for Java. In 30th European Conference on Object-Oriented Programming, ECOOP 2016, July 18-22, 2016, Rome, Italy . 22:1–22:26.Google Scholar
- Mirko Streckenbach and Gregor Snelting. 2004. Refactoring Class Hierarchies with KABA. In Proceedings of the 19th Annual ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications (OOPSLA ’04) . ACM, New York, NY, USA, 315–330. Google Scholar
Digital Library
- Lance Tokuda and Don Batory. 2001. Evolving Object-Oriented Designs with Refactorings. Automated Software Engg. 8, 1 (Jan. 2001), 89–120. Google Scholar
Digital Library
- Nikolaos Tsantalis. 2018. https://users.encs.concordia.ca/~nikolaos/stats.html .Google Scholar
- Nikolaos Tsantalis and Alexander Chatzigeorgiou. 2009. Identification of move method refactoring opportunities. IEEE Transactions on Software Engineering 35, 3 (2009), 347–367. Google Scholar
Digital Library
- Nikolaos Tsantalis and Alexander Chatzigeorgiou. 2010. Identification of refactoring opportunities introducing polymorphism. Journal of Systems and Software 83, 3 (2010), 391–404. Google Scholar
Digital Library
- Jyothi Vedurada and V Krishna Nandivada. 2017. Refactoring Opportunities for Replacing Type Code with State and Subclass. In Proceedings of the 39th International Conference on Software Engineering Companion (ICSE-C ’17). IEEE Press, Piscataway, NJ, USA, 305–307. Google Scholar
Digital Library
- Jyothi Vedurada and V. Krishna Nandivada. 2018. Supplementary Material. https://github.com/anony-user/Auto-SCST .Google Scholar
- John Whaley and Martin Rinard. 1999. Compositional Pointer and Escape Analysis for Java Programs. In Proceedings of the 14th ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications (OOPSLA ’99) . ACM, New York, NY, USA, 187–206. Google Scholar
Digital Library
Index Terms
Identifying refactoring opportunities for replacing type code with subclass and state
Recommendations
Refactoring opportunities for replacing type code with state and subclass
ICSE-C '17: Proceedings of the 39th International Conference on Software Engineering CompanionRefactoring 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 ...
Tool-Supported Refactoring of Existing Object-Oriented Code into Aspects
Aspect-Oriented Programming (AOP) provides mechanisms for the separation of crosscutting concerns—functionalities scattered through the system and tangled with the base code. Existing systems are a natural testbed for the AOP approach since they often ...
Aspect-Oriented Refactoring of Legacy Applications: An Evaluation
The primary claimed benefits of aspect-oriented programming (AOP) are that it improves the understandability and maintainability of software applications by modularizing crosscutting concerns. Before there is widespread adoption of AOP, developers need ...






Comments