skip to main content

Identifying refactoring opportunities for replacing type code with subclass and state

Published:24 October 2018Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

a138-vedurada.webm

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. Serge Demeyer, Stéphane Ducasse, and Oscar Nierstrasz. 2002. Object-oriented reengineering patterns. Elsevier. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Eclipse. 2017. Eclipse: A Java Integrated Development Environment (IDE). https://eclipse.org/Google ScholarGoogle Scholar
  8. M. Fowler. 1999. Refactoring: Improving the Design of Existing Code. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. William H. Harrison. 1977. Compiler Analysis of the Value Ranges for Variables. IEEE Transactions on Software Engineering SE-13, 3 (May 1977). Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle ScholarCross RefCross Ref
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. Joshua Kerievsky. 2005. Refactoring to patterns. Pearson Deutschland GmbH. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. T. J. McCabe. 1976. A Complexity Measure. IEEE Trans. Softw. Eng. 2, 4 (July 1976), 308–320. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. Sourceforge. 2016. SoureForge. https://sourceforge.net/Google ScholarGoogle Scholar
  25. 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 ScholarGoogle Scholar
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. Lance Tokuda and Don Batory. 2001. Evolving Object-Oriented Designs with Refactorings. Automated Software Engg. 8, 1 (Jan. 2001), 89–120. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Nikolaos Tsantalis. 2018. https://users.encs.concordia.ca/~nikolaos/stats.html .Google ScholarGoogle Scholar
  29. Nikolaos Tsantalis and Alexander Chatzigeorgiou. 2009. Identification of move method refactoring opportunities. IEEE Transactions on Software Engineering 35, 3 (2009), 347–367. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Nikolaos Tsantalis and Alexander Chatzigeorgiou. 2010. Identification of refactoring opportunities introducing polymorphism. Journal of Systems and Software 83, 3 (2010), 391–404. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  32. Jyothi Vedurada and V. Krishna Nandivada. 2018. Supplementary Material. https://github.com/anony-user/Auto-SCST .Google ScholarGoogle Scholar
  33. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Identifying refactoring opportunities for replacing type code with subclass and state

            Recommendations

            Comments

            Login options

            Check if you have access through your login credentials or your institution to get full access on this article.

            Sign in

            Full Access

            PDF Format

            View or Download as a PDF file.

            PDF

            eReader

            View online with eReader.

            eReader
            About Cookies On This Site

            We use cookies to ensure that we give you the best experience on our website.

            Learn more

            Got it!