skip to main content
research-article

Code-Smell Detection as a Bilevel Problem

Published: 14 October 2014 Publication History

Abstract

Code smells represent design situations that can affect the maintenance and evolution of software. They make the system difficult to evolve. Code smells are detected, in general, using quality metrics that represent some symptoms. However, the selection of suitable quality metrics is challenging due to the absence of consensus in identifying some code smells based on a set of symptoms and also the high calibration effort in determining manually the threshold value for each metric. In this article, we propose treating the generation of code-smell detection rules as a bilevel optimization problem. Bilevel optimization problems represent a class of challenging optimization problems, which contain two levels of optimization tasks. In these problems, only the optimal solutions to the lower-level problem become possible feasible candidates to the upper-level problem. In this sense, the code-smell detection problem can be treated as a bilevel optimization problem, but due to lack of suitable solution techniques, it has been attempted to be solved as a single-level optimization problem in the past. In our adaptation here, the upper-level problem generates a set of detection rules, a combination of quality metrics, which maximizes the coverage of the base of code-smell examples and artificial code smells generated by the lower level. The lower level maximizes the number of generated artificial code smells that cannot be detected by the rules produced by the upper level. The main advantage of our bilevel formulation is that the generation of detection rules is not limited to some code-smell examples identified manually by developers that are difficult to collect, but it allows the prediction of new code-smell behavior that is different from those of the base of examples. The statistical analysis of our experiments over 31 runs on nine open-source systems and one industrial project shows that seven types of code smells were detected with an average of more than 86% in terms of precision and recall. The results confirm the outperformance of our bilevel proposal compared to state-of-art code-smell detection techniques. The evaluation performed by software engineers also confirms the relevance of detected code smells to improve the quality of software systems.

References

[1]
Alain Abran and Hong Nguyenkim. 1993. Measurement of the maintenance process from a demand-based perspective. J. Softw. Maint. Res. Pract. 5, 2 (1993), 63--90.
[2]
Eitaro Aiyoshi and Kiyotaka Shimizu. 1981. Hierarchical decentralized systems and its new solution by a barrier method. IEEE Trans. Syst. Man Cybernet. 11, 6 (1981), 444--449.
[3]
Bente C. D. Anda. 2007. Assessing software system maintainability using structural measures and expert assessments. In Proceedings of the IEEE International Conference on Software Maintenance (ICSM'07). 204--213.
[4]
Andrea Arcuri and Gordon Fraser. 2013. Parameter tuning or default values? An empirical investigation in search-based software engineering. Emp. Softw. Eng. 18, 3 (2013), 594--623.
[5]
Jagdish Bansiya and Carl G. Davis. 2002. A hierarchical model for object-oriented design quality assessment. IEEE Trans. Softw. Eng. 28, 1 (2002), 4--17.
[6]
Jonathan F. Bard and James E. Falk. 1982. An explicit solution to the multi-level programming problem. Comput. Oper. Res. 9, 1, 77--100.
[7]
J. Bard. 1998. Practical Bilevel Optimization: Algorithms and Applications. Kluwer Academic Publishers, The Netherlands.
[8]
Victor R. Basili, Lionel C. Briand, and Walcélio L. Melo. 1996. A validation of object-oriented design metrics as quality indicators. IEEE Trans. Softw. Eng. 22, 10 (1996), 751--761.
[9]
Keith H. Bennett and Václav T. Rajlich. 2000. Software maintenance and evolution: A roadmap. In Proceedings of the Conference on The Future of Software Engineering (ICSE'00). ACM, New York, NY, 73--87.
[10]
Wayne F. Bialas, Mark H. Karwan, and J. Shaw. 1980. A parametric complementarity pivot approach for two-level linear programming. Technical Report 80-2, Operations Research Program, State University of New York at Buffalo.
[11]
Mohamed Boussaa, Wael Kessentini, Marouane Kessentini, Slim Bechikh, and Soukeina Ben Chikha. 2013. Competitive coevolutionary code-smells detection. In Proceedings of the 5th IEEE Symposium on Search-Based Software Engineering (SSBSE'13). 50--65.
[12]
J. Bracken and J. McGill. 1973. Mathematical programs with optimization problems in the constraints. Oper. Res. 21, 1 (1973), 37--44.
[13]
Lionel C. Briand, Khaled E. Emam, and Sandro Morasca. 1995. Theoretical and empirical validation of software metrics. In Proceedings of the International Software Engineering Research Network.
[14]
Lionel C. Briand, John W. Daly, and Jürgen K. Wüst. 1999. A unified framework for coupling measurement in object-oriented systems. IEEE Trans. Softw. Eng. 25, 1 (1999), 91--121.
[15]
Fernando Brito e Abreu and Walcelio Melo. 1996. Evaluating the impact of object-oriented design on software quality. In Proceedings of the 3rd International Symposium on Software Metrics: From Measurement to Empirical Results (METRICS'96). IEEE Computer Society, 90--99.
[16]
Fernando Brito e Abreu. 1995. The MOOD metrics set. In Proceedings of the European Conference on Object--Oriented Programming (ECOOP'95) Workshop on Metrics.
[17]
William J. Brown, Raphael C. Malveau, Hays W. McCormick, III, and Thomas J. Mowbray. 1998. Antipatterns: Refactoring Software, Architectures, and Projects in Crisis. John Wiley & Sons, Inc., New York, NY.
[18]
Herminia I. Calvete and Carmen Galé. 2010. A multiobjective bilevel program for production-distribution planning in a supply chain. In Multiple Criteria Decision Making for Sustainable Energy and Transportation Systems, Lecture Notes in Computer Science, vol. 634, Springer-Verlag, Berlin/Heidelberg, 155--165.
[19]
Wilfred Candler and Robert Townsley. 1982. A linear two-level programming problem. Comput. Oper. Res. 9, 1, 59--76.
[20]
Syham R. Chidamber and Chris F. Kemerer. 1994. A metrics suite for object oriented design. IEEE Trans. Softw. Eng. 20, 6 (1994), 476--493.
[21]
Neville I. Churcher and Martin J. Shepperd. 1995. Comments on ‘A Metrics Suite for Object Oriented Design’. IEEE Trans. Softw. Eng. 21, 3 (1995), 263--265.
[22]
Oliver Ciupke. 1999. Automatic detection of design problems in object-oriented reengineering. In Proceedings of the Technology of Object-Oriented Languages and Systems (TOOLS'99). IEEE Computer Society, 18--32.
[23]
Peter Coad and Edward Yourdon. 1991. Object-Oriented Design. Yourdon Press, Upper Saddle River, NJ.
[24]
Benoit Colson, Patrice Marcotte, and Gilles Savard. 2005a. A trust-region method for nonlinear bilevel programming: Algorithm and computational experience. Comput. Optim. Appl. 30, 3 (2005), 211--227.
[25]
Benoit Colson, Patrice Marcotte, and Gilles Savard. 2005b. Bilevel programming: A survey. 4OR 3, 2 (2005), 87--107.
[26]
Marco D'Ambros, Alberto Bacchelli, and Michele Lanza. 2010. On the impact of design flaws on software defects. In Proceedings of the 10th International Conference on Quality Software (QSIC'10). 23--31.
[27]
Ignatios Deligiannis, Martin Shepperd, Manos Roumeliotis, and Ioannis Stamelos. 2003. An empirical investigation of an object-oriented design heuristic for maintainability. J. Syst. Softw. 65, 2 (2003), 127--139.
[28]
Ignatios Deligiannis, Ioannis Stamelos, Lefteris Angelis, Manos Roumeliotis, and Martin Shepperd. 2004. A controlled experiment investigation of an object-oriented design heuristic for maintainability. J. Syst. Softw. 72, 2 (2004), 129--143.
[29]
Karim Dhambri, Houari A. Sahraoui, and Pierre Poulin. 2008. Visual detection of design anomalies. In Proceedings of the 12th European Conference on Software Maintenance and Reengineering (CSMR'08). 279--283.
[30]
Karin Erni and Claus Lewerentz. 1996. Applying design metrics to object-oriented frameworks. In Proceedings of the 3rd International Symposium on Software Metrics: From Measurement to Empirical Results (METRICS'96). 64.
[31]
Norman E. Fenton and Shari Lawrence Pfleeger. 1998. Software Metrics: A Rigorous and Practical Approach 2nd Ed. PWS Pub. Co., Boston, MA.
[32]
Martin Fowler, Kent Beck, John Brant, William Opdyke, and Don Roberts. 1999. Refactoring: Improving the Design of Existing Code 1st Ed. Addison-Wesley.
[33]
David E. Goldberg. 1989. Genetic Algorithms in Search, Optimization and Machine Learning 1st Ed. Addison-Wesley Longman Publishing Co., Inc., Boston, MA.
[34]
Mark Harman, S. Afshin Mansouri, and Yuanyuan Zhang. 2012. Search-based software engineering: Trends, techniques and applications. ACM Comput. Surv. 45, 1, (2012), Article 11.
[35]
Mark Harman. 2007. The current state and future of search based software engineering. In Proceedings of the Future of Software Engineering (FOSE'07). IEEE Computer Society, 342--357.
[36]
Rachel Harrison, Steve J. Counsell, and Reuben V. Nithi. 1998. An evaluation of the MOOD set of object-oriented software metrics. IEEE Trans. Softw. Eng. 24, 6 (1998), 491--496.
[37]
Sture Holm. 1979. A simple sequentially rejective multiple test procedure. Scand. J. Stat. 6, 2, 65--70.
[38]
Marouane Kessentini, Stéphane Vaucher, and Houari Sahraoui. 2010. Deviance from perfection is a better criterion than closeness to evil when identifying risky code. In Proceedings of the IEEE/ACM International Conference on Automated Software Engineering (ASE'10). ACM, New York, NY, 113--122.
[39]
Marouane Kessentini, Wael Kessentini, Houari A. Sahraoui, Mounir Boukadoum, and Ali Ouni. 2011. Design defects detection and correction by example. In Proceedings of the 19th IEEE International Conference on Program Comprehension (ICPC'11). 81--90.
[40]
Foutse Khomh, Stéphane Vaucher, Yann G. Guéhéneuc, and Houari A. Sahraoui. 2009. A Bayesian approach for the detection of code and design smells. In Proceedings of the 9th International Conference on Quality Software (QSIC'09).
[41]
Andrew Koh. 2013. A metaheuristic framework for bi-level programming problems with multi-disciplinary applications. In Metaheuristics for Bi-level Optimization, Studies in Computational Intelligence, Vol. 482, Springer-Verlag, Berlin/Heidelberg, 153--87.
[42]
Charles D. Kolstad. 1985. A review of the literature on bi-level mathematical programming. Technical Report LA-10284-MS, Los Alamos National Laboratory, Los Alamos, NM.
[43]
S. C. Kothari, Luke Bishop, Jeremias Sauceda, and Gary Daugherty. 2004. A pattern-based framework for software anomaly detection. Softw. Qual. Control 12, 2 (2004), 99--120.
[44]
Guillaume Langelier, Houari Sahraoui, and Pierre Poulin. 2005. Visualization-based analysis of quality for large-scale software systems. In Proceedings of the 20th IEEE/ACM International Conference on Automated Software Engineering (ASE'05). ACM, New York, NY, 214--223.
[45]
François Legillon, Arnaud Liefooghe, and El-Ghazali G. Talbi. 2012. CoBRA: A cooperative coevolutionary algorithm for bi-level optimization. In Proceedings of the IEEE Congress on Evolutionary Computation (CEC'12). 1--8.
[46]
Wei Li and Raed Shatnawi. 2007. An empirical study of the bad smells and class error probability in the post-release object-oriented system evolution. J. Syst. Softw. 80, 7 (2007), 1120--1128.
[47]
Hui Liu, Limei Yang, Zhendong Niu, Zhyi Ma, and Weizhong Shao. 2009. Facilitating software refactoring with appropriate resolution order of bad smells. In Proceedings of the 7th Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on the Foundations of Software Engineering (ESEC/FSE'09). ACM, New York, NY, 265--268.
[48]
Radu Marinescu. 2004. Detection strategies: Metrics-based rules for detecting design flaws. In Proceedings of the 20th IEEE International Conference on Software Maintenance (ICSM'04). IEEE Computer Society, 350--359.
[49]
Mäntylä Mika and Casper Lassenius. 2006. Subjective evaluation of software evolvability using code smells: An empirical study. Emp. Softw. Eng. 11, 3 (2006), 395--431.
[50]
Mäntylä Mika, Jari Vanhanen, and Casper Lassenius. 2003. A taxonomy and an initial empirical study of bad smells in code. In Proceedings of the International Conference on Software Maintenance (ICSM'03). IEEE Computer Society, 381--384.
[51]
Mäntylä Mika. 2010. Empirical software evolvability—Code smells and human evaluations. In Proceedings of the International Conference on Software Maintenance (ICSM'10). 1--6.
[52]
R. Mathieu, L. Pittard, and G. Anandalingam. 1994. Genetic algorithm based approach to bi-level linear programming. Oper. Res. 28, 1, 1--21.
[53]
Naouel Moha, Yann-Gaël Guéhéneuc, Laurence Duchien, and Anne F. Le Meur. 2010. DECOR: A method for the specification and detection of code and design smells. IEEE Trans. Softw. Eng. 36, 1 (2010), 20--36.
[54]
Akito Monden, Daikai Nakae, Toshihiro Kamiya, Shin-ichi Sato, and Ken-ichi Matsumoto. 2002. Software quality analysis by code clones in industrial legacy software. In Proceedings of the 8th International Symposium on Software Metrics (METRICS'02). IEEE Computer Society, 87--94.
[55]
Matthew James Munro. 2005. Product metrics for automatic identification of “bad smell” design problems in Java source-code. In Proceedings of the 11th IEEE International Software Metrics Symposium (METRICS'05). IEEE Computer Society.
[56]
Ali Ouni, Marouane Kessentini, Hauari A. Sahraoui, and Mounir Boukadoum. 2012. Maintainability defects detection and correction: A multi-objective approach. J Autom. Softw. Eng. 20, 1 (2013), 47--79.
[57]
Francesco Palomba, G. Bavota, Massimiliano Di Penta, Rocco Oliveto, Andrea De Lucia, and Denys Poshyvanyk. 2013. Detecting bad smells in source code using change history information. In Proceedings of the 28th IEEE/ACM International Conference on Automated Software Engineering (ASE'13). 268--278.
[58]
Foyzur Rahman, Christian Bird, and Premkumar Devanbu. 2012. Clones: What is that smell? Emp. Softw. Eng. 17, 4--5 (2012), 503--530.
[59]
Daniel Ratiu, Stéphane Ducasse, Tudor Gîrba, and Radu Marinescu. 2004. Using history information to improve design flaws detection. In Proceedings of the 8th Euromicro Working Conference on Software Maintenance and Reengineering (CSMR'04). IEEE Computer Society, 223--232.
[60]
Arthur J. Riel. 1996. Object-Oriented Design Heuristics (1st ed.). Addison-Wesley, Boston, MA.
[61]
Mazeiar Salehie, Sen Li, and Ladan Tahvildari. 2006. A metric-based heuristic framework to detect object-oriented design flaws. In Proceedings of the 14th IEEE International Conference on Program Comprehension (ICPC'06). 159--168.
[62]
Gilles Savard and Jacques Gauvin. 1994. The steepest descent direction for the nonlinear bilevel programming problem. Oper. Res. Lett. 15, 5 (1994), 265--272.
[63]
Ankur Sinha, Pekka Malo, and Kalyanmoy Deb. 2013a. Efficient evolutionary algorithm for single-objective bilevel optimization. KanGAL Report No. 2013003.
[64]
Ankur Sinha, Pekka Malo, Anton Frantsev, and Kalyanmoy Deb. 2013b. Multi-objective Stackelberg game between a regulating authority and a mining company: A case study in environmental economics. In Proceedings of the IEEE Congress on Evolutionary Computation. 478--485.
[65]
Dag I. K. Sjøberg, Aiko Fallas Yamashita, Bente Cecilie, Dahlum Anda, Audris Mockus, and Tore Dybå. 2013. Quantifying the effect of code smells on maintenance effort. IEEE Trans. Softw. Eng. 39, 8 (2013), 1144--1156.
[66]
Guilherme Travassos, Forrest Shull, Michael Fredericks, and Victor R. Basili. 1999. Detecting defects in object-oriented designs: Using reading techniques to increase software quality. In Proceedings of the 14th ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA'99), A. Michael Berman (Ed.). ACM, New York, NY, 47--56.
[67]
Douglas A. Troy and Stuart H. Zweben. 1981. Measuring the quality of structured designs. J. Syst. Softw. 2, 2 (1981), 113--120.
[68]
E. Van Emden and L. Moonen. 2002. Java quality assurance by detecting code smells. In Proceedings of the 9th Working Conference on Reverse Engineering (WCRE'02). IEEE Computer Society, 97--106.
[69]
Luís N. Vicente and Paul H. Calamai. 1994. Bilevel and multilevel programming: A bibliography review. J. Global Optim. 5, 3 (1994), 291--306.
[70]
Aiko F. Yamashita and Leon Moonen. 2013a. Do developers care about code smells? An exploratory survey. In Proceedings of the 20th Working Conference on Reverse Engineering (WCRE'13). 242--251.
[71]
Aiko Yamashita and Leon Moonen. 2013b. To what extent can maintenance problems be predicted by code smell detection? An empirical study. Inf. Softw. Technol. 55, 12 (2013), 2223--2242.
[72]
Aiko F. Yamashita and Leon Moonen. 2012. Do code smells reflect important maintainability aspects? In Proceedings of the IEEE International Conference on Software Maintenance (ICSM'12). IEEE Computer Society, 306--315.
[73]
Min Zhang, Tracy Hall, and Nathan Baddoo. 2011. Code bad smells: A review of current knowledge. J. Softw. Maint. Evol. 23, 3 (2011), 179--202.

Cited By

View all

Index Terms

  1. Code-Smell Detection as a Bilevel Problem

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Transactions on Software Engineering and Methodology
    ACM Transactions on Software Engineering and Methodology  Volume 24, Issue 1
    September 2014
    226 pages
    ISSN:1049-331X
    EISSN:1557-7392
    DOI:10.1145/2676679
    Issue’s Table of Contents
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 14 October 2014
    Accepted: 01 August 2014
    Revised: 01 March 2014
    Received: 01 November 2013
    Published in TOSEM Volume 24, Issue 1

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Search-based software engineering
    2. code smells
    3. software quality

    Qualifiers

    • Research-article
    • Research
    • Refereed

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)37
    • Downloads (Last 6 weeks)3
    Reflects downloads up to 04 Jan 2025

    Other Metrics

    Citations

    Cited By

    View all

    View Options

    Login options

    Full Access

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media