Skip to main content
Log in

Automated pattern-directed refactoring for complex conditional statements

  • Published:
Journal of Central South University Aims and scope Submit manuscript

Abstract

Complex conditional statement is one of the bad code smells, which affects the quality of the code and design of software. In the proposed approach, two commonly-used design patterns for handling complex conditional statements are selected, and they are the factory method pattern and the strategy pattern. Two pattern-directed refactoring approaches based on the two design patterns are proposed. Each approach contains a refactoring opportunities identification algorithm and an automated refactoring algorithm. After parsing the abstract syntax tree generated from source code, the refactoring opportunities are identified effectively and automatically. Then, for candidate code, refactoring algorithms are executed automatically, which are used to simplify or remove complex conditional statements. By empirical analysis and quality assessment, the code after refactoring has better maintainability and extensibility, and the proposed approach for automated pattern-directed refactoring succeeds to reduce code size and complexity of classes.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. FOWLER M, BECK K. Refactoring-Improving the design of existing code [M]. Massachusetts: Addison-Wesley, 1999: 63–71.

    Google Scholar 

  2. VAKILIAN M, CHEN N, NEGARA S, RAJKUMAR A B, BAILEY P B, JOHNSON E R. Use, disuse, and misuse of automated refactorings [C]// Proceedings of the 34th International Conference on Software Engineering (ICSE). Zurich, 2012: 233–243.

    Google Scholar 

  3. MURPHY-HILL E, PARNIN C, BLACK A P. How we refactor, and how we know It [J]. IEEE Transaction on Software Engineering, 2012, 38(1): 5–18.

    Article  Google Scholar 

  4. DALLAL J A. Constructing models for predicting extract subclass refactoring opportunities using object-oriented quality metrics [J]. Information and Software Technology, 2012, 54(10): 1125–1141.

    Article  Google Scholar 

  5. TSANTALIS N, CHATZIGEORGIOU A. Identification of move method refactoring opportunities [J]. IEEE Transaction on Software Engineering, 2009, 35(3): 347–367.

    Article  Google Scholar 

  6. TSANTALIS N, CHATZIGEORGIOU A. Identification of extract method refactoring opportunities [C]// Proceedings of the 13th European Conference on Software Maintenance and Reengineering (CSMR’09). Kaiserslautern, 2009: 119–128.

    Chapter  Google Scholar 

  7. TSANTALIS N, CHATZIGEORGIOU A. Identification of extract method refactoring opportunities for the decomposition of methods [J]. Journal of Systems and Software, 2011, 84(10): 1757–1782.

    Article  Google Scholar 

  8. TSANTALIS N, CHATZIGEORGIOU A. Identification of refactoring opportunities introducing polymorphism [J]. Journal of Systems and Software, 2010, 83(3): 391–404.

    Article  Google Scholar 

  9. FOKAEFS M, TSANTALIS N, STROULIA E, CHATZIGEORGIOU A. Identification and application of extract class refactorings in object-oriented systems [J]. Journal of Systems and Software, 2012, 85(10): 2241–2260.

    Article  Google Scholar 

  10. BAVOTA G, De LUCIA A, OLIVETO R. Identifying extract class refactoring opportunities using structural and semantic cohesion measures [J]. Journal of Systems and Software, 2011, 84(3): 397–414.

    Article  Google Scholar 

  11. LIU Hui, NIU Zhen-dong, MA Zhi-yi, SHAO Wei-zhong. Identification of generalization refactoring opportunities [J]. Automated Software Engineering, 2013, 20(1): 81–110.

    Article  Google Scholar 

  12. HIGO Y, KUSUMOTO S, INOUE K. A metric-based approach to identifying refactoring opportunities for merging code clones in a Java software system [J]. Journal of Software Maintenance and Evolution: Research and Practice, 2008, 20(6): 435–461.

    Article  Google Scholar 

  13. KOMONDOOR R, HORWITZ S. Using slicing to identify duplication in source code [C]// Proceedings of the 8th International Symposium on Static Analysis. Paris, 2001: 40–56.

    Google Scholar 

  14. KERIEVSKY J. Refactoring to patterns [M]. Massachusetts: Addison-Wesley, 2004: 52–54.

    Google Scholar 

  15. GAMMA E, HELM R, JOHNSON R, VLISSIDES J. Design patterns: Elements of reusable object-oriented software [M]. Massachusetts: Addison-Wesley, 1995: 8–9.

    Google Scholar 

  16. CHRISTOPOULOU A, GIAKOUMAKIS E A, ZAFEIRIS V E, SOUKARA V. Automated refactoring to the Strategy design pattern [J]. Information and Software Technology, 2012, 54(11): 1202–1214.

    Article  Google Scholar 

  17. JEBELEAN C, CHIRILA C B, CRETU V. A logic based approach to locate composite refactoring opportunities in object-oriented code [C]// Proceedings of the 2010 IEEE International Conference on Automation Quality and Testing Robotics (AQTR). Cluj-Napoca, 2010: 1–6.

    Chapter  Google Scholar 

  18. JEON S U, LEE J S, BAE D H. An automated refactoring approach to design pattern-based program transformations in java programs [C]// Proceedings of the 9th Asia-Pacific Software Engineering Conference (APSEC). Queensland, 2002: 337–345.

    Google Scholar 

  19. JUILLERAT N, HIRSBRUNNER B. Toward an Implementation of the “Form Template Method” [C]// Proceedings of the 7th IEEE International Working Conference on Source Code Analysis and Manipulation (SCAM 2007). Paris, 2007: 81–90.

    Chapter  Google Scholar 

  20. KUHN T, THOMANN O. Eclipse corner article abstract syntax tree [EB/OL]. [2006-11-20]. http://www.eclipse.org/articles/Article-JavaCodeManipulationAST/index.html.

  21. Eclipse-The Eclipse Foundation open source community website. [EB/OL]. [2013-04-16]. http://www.eclipse.org/.

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Zhi-gang Hu  (胡志刚).

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Liu, W., Hu, Zg., Liu, Ht. et al. Automated pattern-directed refactoring for complex conditional statements. J. Cent. South Univ. 21, 1935–1945 (2014). https://doi.org/10.1007/s11771-014-2140-z

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s11771-014-2140-z

Key words

Navigation