Software & Systems Modeling

, Volume 16, Issue 1, pp 77–96

The shape of feature code: an analysis of twenty C-preprocessor-based systems

  • Rodrigo Queiroz
  • Leonardo Passos
  • Marco Tulio Valente
  • Claus Hunsen
  • Sven Apel
  • Krzysztof Czarnecki
Theme Section Paper

DOI: 10.1007/s10270-015-0483-z

Cite this article as:
Queiroz, R., Passos, L., Valente, M.T. et al. Softw Syst Model (2017) 16: 77. doi:10.1007/s10270-015-0483-z

Abstract

Feature annotations (e.g., code fragments guarded by #ifdef C-preprocessor directives) control code extensions related to features. Feature annotations have long been said to be undesirable. When maintaining features that control many annotations, there is a high risk of ripple effects. Also, excessive use of feature annotations leads to code clutter, hinder program comprehension and harden maintenance. To prevent such problems, developers should monitor the use of feature annotations, for example, by setting acceptable thresholds. Interestingly, little is known about how to extract thresholds in practice, and which values are representative for feature-related metrics. To address this issue, we analyze the statistical distribution of three feature-related metrics collected from a corpus of 20 well-known and long-lived C-preprocessor-based systems from different domains. We consider three metrics: scattering degree of feature constants, tangling degree of feature expressions, and nesting depth of preprocessor annotations. Our findings show that feature scattering is highly skewed; in 14 systems (70 %), the scattering distributions match a power law, making averages and standard deviations unreliable limits. Regarding tangling and nesting, the values tend to follow a uniform distribution; although outliers exist, they have little impact on the mean, suggesting that central statistics measures are reliable thresholds for tangling and nesting. Following our findings, we then propose thresholds from our benchmark data, as a basis for further investigations.

Keywords

Software families Preprocessor Feature-related metrics Thresholds Power-law distribution 

Copyright information

© Springer-Verlag Berlin Heidelberg 2015

Authors and Affiliations

  • Rodrigo Queiroz
    • 1
  • Leonardo Passos
    • 2
  • Marco Tulio Valente
    • 1
  • Claus Hunsen
    • 3
  • Sven Apel
    • 3
  • Krzysztof Czarnecki
    • 2
  1. 1.Federal University of Minas GeraisBelo HorizonteBrazil
  2. 2.University of WaterlooWaterlooCanada
  3. 3.University of PassauPassauGermany

Personalised recommendations