Design Defects Detection and Correction by Example

Detecting and fixing defects make programs easier to understand by developers. We propose an automated approach for the detection and correction of various types of design defects in source code. Our approach allows to automatically find detection rules, thus relieving the designer from doing so manually. Rules are defined as combinations of metrics/thresholds that better conform to known instances of design defects (defect examples). The correction solutions, a combination of refactoring operations, should minimize, as much as possible, the number of defects detected using the detection rules. In our setting, we use genetic programming for rule extraction. For the correction step, we use genetic algorithm. We evaluate our approach by finding and fixing potential defects in four open-source systems. For all these systems, we found, in average, more than 80% of known defects, a better result when compared to a state-of-the-art approach, where the detection rules are manually or semi-automatically specified. The proposed corrections fix, in average, more than 78%of detected defects.

[1]  C. D. Gelatt,et al.  Optimization by Simulated Annealing , 1983, Science.

[2]  Suraj C. Kothari,et al.  A Pattern-Based Framework for Software Anomaly Detection , 2004, Software Quality Journal.

[3]  William G. Griswold,et al.  Automated support for program refactoring using invariants , 2001, Proceedings IEEE International Conference on Software Maintenance. ICSM 2001.

[4]  John R. Koza,et al.  Genetic programming - on the programming of computers by means of natural selection , 1993, Complex adaptive systems.

[5]  Yann-Gaël Guéhéneuc,et al.  DECOR: A Method for the Specification and Detection of Code and Design Smells , 2010, IEEE Transactions on Software Engineering.

[6]  Mel Ó Cinnéide,et al.  Journal of Software Maintenance and Evolution: Research and Practice Search-based Refactoring: an Empirical Study , 2022 .

[7]  Mel Ó Cinnéide,et al.  Search-based refactoring: an empirical study , 2008 .

[8]  De Raedt,et al.  Advances in Inductive Logic Programming , 1996 .

[9]  Pierre Poulin,et al.  Visual Detection of Design Anomalies , 2008, 2008 12th European Conference on Software Maintenance and Reengineering.

[10]  David E. Goldberg,et al.  Genetic Algorithms in Search Optimization and Machine Learning , 1988 .

[11]  H. Sahraoui,et al.  Model Transformation as an Optimization Problem , 2008, MoDELS.

[12]  Yuhui Shi,et al.  Particle swarm optimization: developments, applications and resources , 2001, Proceedings of the 2001 Congress on Evolutionary Computation (IEEE Cat. No.01TH8546).

[13]  Zhendong Niu,et al.  Facilitating software refactoring with appropriate resolution order of bad smells , 2009, ESEC/FSE '09.

[14]  Shari Lawrence Pfleeger,et al.  Software Metrics : A Rigorous and Practical Approach , 1998 .

[15]  Radu Marinescu,et al.  Detection strategies: metrics-based rules for detecting design flaws , 2004, 20th IEEE International Conference on Software Maintenance, 2004. Proceedings..

[16]  Houari A. Sahraoui,et al.  Deviance from perfection is a better criterion than closeness to evil when identifying risky code , 2010, ASE.

[17]  Thomas J. Mowbray,et al.  AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis , 1998 .

[18]  Tom Mens,et al.  A survey of software refactoring , 2004, IEEE Transactions on Software Engineering.

[19]  Arthur J. Riel,et al.  Object-Oriented Design Heuristics , 1996 .

[20]  John E. Gaffney,et al.  Metrics in software quality assurance , 1981, ACM '81.

[21]  William C. Wake,et al.  Refactoring Workbook , 2003 .

[22]  Foutse Khomh,et al.  A Bayesian Approach for the Detection of Code and Design Smells , 2009, 2009 Ninth International Conference on Quality Software.

[23]  Mika Mäntylä,et al.  A taxonomy and an initial empirical study of bad smells in code , 2003, International Conference on Software Maintenance, 2003. ICSM 2003. Proceedings..

[24]  Claus Lewerentz,et al.  Applying design-metrics to object-oriented frameworks , 1996, Proceedings of the 3rd International Software Metrics Symposium.

[25]  John A. Clark,et al.  Metrics are fitness functions too , 2004, 10th International Symposium on Software Metrics, 2004. Proceedings..