DOI QR코드

DOI QR Code

Automated Code Smell Detection and Refactoring using OCL

OCL을 이용한 자동화된 코드스멜 탐지와 리팩토링

  • Published : 2008.12.31

Abstract

Refactoring is a kind of software modification process that improves system qualities internally but maintains system functions externally. What should be improved on the existing source codes should take precedence over the others in such a modification process using this refactoring. Martin Fowler and Kent Beck proposed a method that identifies code smells for this purpose. Also, some studies on determining what refactoring will be applied to which targets through detecting code smells in codes were presented. However, these studies have a lot of disadvantages that show a lack of precise description for such code smells and detect limited code smells only. In addition, these studies showed other disadvantages that generate ambiguity in behavior preservation due to the fact that a description method of pre-conditions for the behavior preservation is included in a refactoring process or unformalized. Thus, our study represents a precise specification of code smells using OCL and proposes a framework that performs a refactoring process through the automatic detection of code smells using an OCL interpreter. Furthermore, we perform the automatic detection in which the code smells are be specified by using OCL to the java program and verify its applicability and effectivity through applying a refactoring process.

리팩토링은 내부적으로는 시스템의 품질을 개선하고, 외부적으로는 시스템의 기능을 유지하는 일종의 소프트웨어를 변경하는 과정이다. 이러한 리팩토링을 적용하여 기존 소스코드를 개선하기 위해서는 개선할 사항이 무엇인지를 아는 것이 우선이다. 이를 위해 Martin Fowler와 Kent Beck은 코드속의 나쁜 냄새(코드스멜)를 식별할 수 있는 방법을 제시 하였다. 또한 코드스멜을 탐지하고 어디에 어떤 리팩토링을 적용할 것인가를 결정하는 문제와 관련된 몇몇 연구가 발표되었다. 그러나 이러한 연구들은 코드스멜에 대한 명확한 표현이 부족하거나 한정된 코드스멜만을 탐지하는 단점이 있다. 그리고 리팩토링을 적용할 경우 행위보존을 위한 선행조건들의 표현방법이 리팩토링 절차에 포함되어 있거나 정형화되지 않아 행위보존의 모호함이 발생되는 단점을 가지고 있다. 이에 본 논문에서는 OCL을 이용하여 코드스멜의 정보를 정확히 명세화하고, OCL 번역기를 통해 코드스멜을 자동으로 탐지하여 리팩토링하는 프레임워크를 제안한다. 또한 적용사례를 통하여 자바소스코드속의 코드스멜을 OCL로 명세화하여 자동탐지하고, 리팩토링을 적용해 봄으로써 활용성과 효용성을 검증해본다.

Keywords

References

  1. Fowler, M. Refactoring. “Improving the Design of Existing Programs,” Addison-Wesley. 1999
  2. Mens, T., Tourwe, T. “A Survey of Software Refactoring,” IEEE Transactions on Software Engineering, February, Vol.30, No.2. pp.126-139, 2004 https://doi.org/10.1109/TSE.2004.1265817
  3. Joshua Kerievsky, “Refactoring to Patterns,” Addison Wesley, 2005
  4. Martin Fowler, “Refactoring:Improving the Design Existing Code,” Addison Wesley, 1999
  5. Stefan Slinger, “Code Smell Detection in Eclipse,” Delft University of Technology, March, 2005
  6. Yoshio Kataoka, Michael D. Ernst, William G. Griswold, and David Notkin, “Automated Support for Program Refactoring using Invariants,” Proc. Int. Conf. On Software Maintenance, pp.736-743, 2001 https://doi.org/10.1109/ICSM.2001.972794
  7. Stephane Ducasse, Matthias Rieger, and Serge Demeyer, “A language independent approach for detecting duplicated code,” In Hongji Yang and Lee white, editors, Proc. Int'l Conf. Software Maintenance, IEEE Computer Society Press, pp.109-118, September, 1999 https://doi.org/10.1109/ICSM.1999.792593
  8. Frank Simon, Frank SteinbruUckner, and Clause Lewerent, “Metrics Based Refactoring,” In Proc. 5th European Conference on Software Maintenance and Reengineering, IEEE Computer Society Press, pp.30-38, 2001 https://doi.org/10.1109/.2001.914965
  9. Object Management Group, “Object Constraint Language Specification, Version 2.0,” http://www.omg.org/technology/ documents/formal/ocl.htm
  10. MoDisco, “MoDisco Tool- Java Abstract Syntax Discovery Tool,” http://www.eclipse.org/gmt/modisco/toolBox/Java AbstractSyntax/
  11. Object Management Group, “MOF 2.0/XMI Mapping Specification, V2.1.1,” http://www.omg.org/technology/documents/ formal/xmi.htm
  12. Eclipse, “OCL for EMF,” http://www.eclipseplugincentral.com/Web_Links-index-req-viewlink-cid-200.html#, updated 2004
  13. Eclipse, “Eclipse Modeling Framework Project,” http://www.eclipse.org/modeling/emf/?project=emf
  14. E. van Emden and L.Moonen, “Java Quality Assurance by Detecting Code Smells,” In Proc. 9th Working Conference on Reverse Engineering IEEE Computer Society Press, October, 2002 https://doi.org/10.1109/WCRE.2002.1173068
  15. R.C. Holt, “Structural Manipulations of Software Architecture using Tarski Relational Algebra,” In Proc. 5th Working Conference on Reverse Engineering (WCRE'98), pp.210-219, 1998
  16. Narbor C. Mendonca, Paulo Henrique M. Maia, Leonardo A. Fonesca, Rossana M.C. Andrade, “RefaX : A Refactoring Framework Based on XML,” Proceedings of the 20th IEEE International Conference on Software Maintenamce (ICSM'04), 2004 https://doi.org/10.1109/ICSM.2004.1357799
  17. Mammas, E. and Kontogiannis, C., “Towards Portable Source Code Representation using XML,” in Proc. of the 7th Working Conference on Reverse Engineering (WCRE, 00), Brisbane, Australia, pp.172-180, November, 2000 https://doi.org/10.1109/WCRE.2000.891464
  18. W3C, “XQuery 1.0 : An XML Query Language,” W3C Recommendation Draft 12 November 2003, Available at http://www.w3c.org/TR/xquery/, 2003
  19. Roberts, D.B, “Practical Analysis for Refactoring,” Ph.D. Thesis, Unversity of Illinois at Urbana-Chanpaign, 1999
  20. Mel O Cinneide, Automated Application of Design Patterns : A Refactoring Approach, Department of Computer Science, Trinity College Dublin, October, 2000
  21. Raul Marticorena, Carlos Lopez, Yania Crespo, Francisco Javier Perez, “Reuse based Refactoring Tools,” Proceedings of 1st Workshop Refactorign Tools(WRT'07), pp.21-22, July, 2007

Cited by

  1. A Composition Check of Composite Refactorings Not Having a Specification of Precondition vol.18D, pp.1, 2011, https://doi.org/10.3745/KIPSTD.2011.18D.1.023