A large scale study on how developers discuss code smells and anti-pattern in Stack Exchange sites

Abstract Context: In this paper, we investigate how developers discuss code smells and anti-patterns across three technical Stack Exchange sites. Understanding developers perceptions of these issues is important to inform and align future research efforts and direct tools vendors to design tailored tools that best suit developers. Method: we mined three Stack Exchange sites and used quantitative and qualitative methods to analyse more than 4000 posts that discuss code smells and anti-patterns.Results: results showed that developers often asked their peers to smell their code, thus utilising those sites as an informal, crowd-based code smell/anti-pattern detector. The majority of questions (556) asked were focused on smells like Duplicated Code, Spaghetti Code, God and Data Classes. In terms of languages, most of discussions centred around popular languages such as C # (772 posts), JavaScript (720) and Java (699), however greater support is available for Java compared to other languages (especially modern languages such as Swift and Kotlin). We also found that developers often discuss the downsides of implementing specific design patterns and ‘flag’ them as potential anti-patterns to be avoided. Some well-defined smells and anti-patterns are discussed as potentially being acceptable practice in certain scenarios. In general, developers actively seek to consider trade-offs to decide whether to use a design pattern, an anti-pattern or not.Conclusion: our results suggest that there is a need for: 1) more context and domain sensitive evaluations of code smells and anti-patterns, 2) better guidelines for making trade-offs when applying design patterns or eliminating smells/anti-patterns in industry, and 3) a unified, constantly updated, catalog of smells and anti-patterns. We conjecture that the crowd-based detection approach considers contextual factors and thus tend to be more trusted by developers than automated detection tools.

[1]  Tracy Hall,et al.  Code Bad Smells: a review of current knowledge , 2011, J. Softw. Maintenance Res. Pract..

[2]  Ali Mesbah,et al.  Mining questions asked by web developers , 2014, MSR 2014.

[3]  Charles A. Sutton,et al.  Why, when, and what: Analyzing Stack Overflow questions by topic, type, and code , 2013, 2013 10th Working Conference on Mining Software Repositories (MSR).

[4]  Emad Shihab,et al.  What are mobile developers asking about? A large scale study using stack overflow , 2016, Empirical Software Engineering.

[5]  Steve Counsell,et al.  Code smells as system-level indicators of maintainability: An empirical study , 2013, J. Syst. Softw..

[6]  Gustavo Pinto,et al.  Mining questions about software energy consumption , 2014, MSR 2014.

[7]  Nenad Medvidovic,et al.  Identifying Architectural Bad Smells , 2009, 2009 13th European Conference on Software Maintenance and Reengineering.

[8]  Gabriele Bavota,et al.  Are test smells really harmful? An empirical study , 2014, Empirical Software Engineering.

[9]  Mira Mezini,et al.  "Jumping Through Hoops": Why do Java Developers Struggle with Cryptography APIs? , 2016, 2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE).

[10]  Diomidis Spinellis,et al.  A survey on software smells , 2018, J. Syst. Softw..

[11]  Francesca Arcelli Fontana,et al.  Automatic detection of bad smells in code: An experimental assessment , 2012, J. Object Technol..

[12]  Jens Dietrich,et al.  On the Existence of High-Impact Refactoring Opportunities in Programs , 2012, ACSC.

[13]  Aiko Fallas Yamashita,et al.  Do developers care about code smells? An exploratory survey , 2013, 2013 20th Working Conference on Reverse Engineering (WCRE).

[14]  Stéphane Ducasse,et al.  Object-Oriented Metrics in Practice , 2005 .

[15]  Bixin Li,et al.  Are Smell-Based Metrics Actually Useful in Effort-Aware Structural Change-Proneness Prediction? An Empirical Study , 2018, 2018 25th Asia-Pacific Software Engineering Conference (APSEC).

[16]  Gabriele Bavota,et al.  When and Why Your Code Starts to Smell Bad (and Whether the Smells Go Away) , 2015, IEEE Transactions on Software Engineering.

[17]  M. Mäntylä,et al.  Subjective evaluation of software evolvability using code smells: An empirical study , 2006, Empirical Software Engineering.

[18]  Joseph A. Konstan,et al.  Evolution of Experts in Question Answering Communities , 2012, ICWSM.

[19]  Yi Sun,et al.  Some Code Smells Have a Significant but Small Effect on Faults , 2014, TSEM.

[20]  V. Braun,et al.  Using thematic analysis in psychology , 2006 .

[21]  Foutse Khomh,et al.  Do Code Smells Impact the Effort of Different Maintenance Programming Activities? , 2016, 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER).

[22]  David Lo,et al.  An empirical study on developer interactions in StackOverflow , 2013, SAC '13.

[23]  Foutse Khomh,et al.  An Exploratory Study of the Impact of Code Smells on Software Change-proneness , 2009, 2009 16th Working Conference on Reverse Engineering.

[24]  Markus Luczak-Rösch,et al.  Man vs Machine – A Study into Language Identification of Stack Overflow Code Snippets , 2019, 2019 IEEE/ACM 16th International Conference on Mining Software Repositories (MSR).

[25]  Martin Fowler,et al.  Refactoring - Improving the Design of Existing Code , 1999, Addison Wesley object technology series.

[26]  Katsuro Inoue,et al.  What do practitioners ask about code clone? a preliminary investigation of stack overflow , 2015, 2015 IEEE 9th International Workshop on Software Clones (IWSC).

[27]  Ciera Jaspan,et al.  Lessons from building static analysis tools at Google , 2018, Commun. ACM.

[28]  Anselm L. Strauss,et al.  Basics of qualitative research : techniques and procedures for developing grounded theory , 1998 .

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

[30]  Jun Wei,et al.  Is spreadsheet ambiguity harmful? detecting and repairing spreadsheet smells due to ambiguous computation , 2014, ICSE.

[31]  Amjed Tahir,et al.  An Empirical Study into the Relationship Between Class Features and Test Smells , 2021, 2016 23rd Asia-Pacific Software Engineering Conference (APSEC).

[32]  Audris Mockus,et al.  Quantifying the Effect of Code Smells on Maintenance Effort , 2013, IEEE Transactions on Software Engineering.

[33]  Aiko Yamashita,et al.  Assessing the capability of code smells to explain maintenance problems: an empirical study combining quantitative and qualitative data , 2013, Empirical Software Engineering.

[34]  Esperanza Manso,et al.  Software Design Smell Detection: a systematic mapping study , 2018, Software Quality Journal.

[35]  Ahmed E. Hassan,et al.  What are developers talking about? An analysis of topics and trends in Stack Overflow , 2014, Empirical Software Engineering.

[36]  Senthil Mani,et al.  Exploring activeness of users in QA forums , 2013, 2013 10th Working Conference on Mining Software Repositories (MSR).

[37]  Amjed Tahir,et al.  Can you tell me if it smells?: A study on how developers discuss code smells and anti-patterns in Stack Overflow , 2018, EASE.

[38]  Gabriele Bavota,et al.  How do API changes trigger stack overflow discussions? a study on the Android SDK , 2014, ICPC 2014.

[39]  Ghulam Rasool,et al.  A review of code smell mining techniques , 2015, J. Softw. Evol. Process..

[40]  Andy Zaidman,et al.  On the Relation of Test Smells to Software Code Quality , 2018, 2018 IEEE International Conference on Software Maintenance and Evolution (ICSME).

[41]  Gabriele Bavota,et al.  Mining Version Histories for Detecting Code Smells , 2015, IEEE Transactions on Software Engineering.

[42]  Yann-Gaël Guéhéneuc,et al.  Are REST APIs for Cloud Computing Well-Designed? An Exploratory Study , 2016, ICSOC.

[43]  Rafael Valencia-García,et al.  Analyzing best practices on Web development frameworks: The lift approach , 2015, Sci. Comput. Program..

[44]  Alexander Chatzigeorgiou,et al.  Identification of Move Method Refactoring Opportunities , 2009, IEEE Transactions on Software Engineering.

[45]  Arie van Deursen,et al.  Detecting and refactoring code smells in spreadsheet formulas , 2013, Empirical Software Engineering.

[46]  Jens Dietrich,et al.  Antipattern and Code Smell False Positives: Preliminary Conceptualization and Classification , 2016, 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER).

[47]  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.

[48]  Foutse Khomh,et al.  An Empirical Study of the Impact of Two Antipatterns, Blob and Spaghetti Code, on Program Comprehension , 2011, 2011 15th European Conference on Software Maintenance and Reengineering.

[49]  Nicole Novielli,et al.  The challenges of sentiment detection in the social programmer ecosystem , 2015, SSE@SIGSOFT FSE.

[50]  Gabriele Bavota,et al.  Do They Really Smell Bad? A Study on Developers' Perception of Bad Code Smells , 2014, 2014 IEEE International Conference on Software Maintenance and Evolution.

[51]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[52]  Antonio Martini,et al.  Identifying and Prioritizing Architectural Debt Through Architectural Smells: A Case Study in a Large Software Company , 2018, ECSA.

[53]  Felipe Ebert,et al.  An Empirical Study on the Usage of the Swift Programming Language , 2016, 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER).

[54]  Peter W. O'Hearn,et al.  Scaling static analyses at Facebook , 2019, Commun. ACM.

[55]  Francesca Arcelli Fontana,et al.  Toward a Smell-Aware Bug Prediction Model , 2019, IEEE Transactions on Software Engineering.

[56]  Mehdi Bagherzadeh,et al.  What do concurrency developers ask about?: a large-scale study using stack overflow , 2018, ESEM.