FeatureCommander: Colorful #ifdef World Janet Feigenspan, Maria Papendieck University of Magdeburg Christian Kästner Philipps University Marburg Mathias Frisch, Raimund Dachselt University of Magdeburg Categories and Subject Descriptors D.2.2 [Software Engineering]: Design Tools and Tech- niques—User interfaces ; D.2.3 [Software Engineering]: Coding Tools and Techniques—Top-down programming Keywords FeatureCommander, Preprocessor, Program Comprehension Software product line engineering is a promising paradigm to create variable software. In practice, conditional compila- tion is often used to implement software product lines, such that code of features is annotated with ifdef directives. How- ever, preprocessor usage can lead to obfuscated source code that is hard to understand and maintain. In the literature, ifdef directives are even referred to as “ifdef hell” [1, 5]. To support developing and maintaining preprocessor-based software, we implemented FeatureCommander. We show a screenshot in Figure 1. FeatureCommander is a prototype that makes consistent use of (a) background colors to high- light source code of features (i.e., code annotated with an ifdef directive) and (b) views to navigate features in the code base. First, we highlight source-code fragments that belong to a feature OPT PRIOCPL (wrapped with #ifdef CONFIG_XENO_ OPT_PRIOCPL) with that feature’s color. The benefit of col- ors is that humans process colors preattentively and, thus, considerably faster than text [3]. In addition to background colors, we illustrate ifdef directives and their nesting with vertical bars next to the code editor. Hence, locating and tracking (scattered, nested, and even very long) conditional code fragments in a file becomes easier. Second, to navigate between features in different files, we provide additional views that use the same color metaphor. In the file browser (explorer view), we represent the amount of feature code using a small bar chart, again using the fea- tures respective colors. Vertical bars in this chart represent the relative amount of feature code, again using each fea- ture’s color. The same visualization is used for files and en- 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. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Copyright SPLC’11, August 21-26, 2011, Munich, Germany ACM 978-1- 4503-0789-5/11/08 ...$10.00. Figure 1: Screenshot of FeatureCommander, show- ing explorer view (left), source-code view (middle), and feature-model view (top right). Colors can be dragged from the color palette (bottom right) and dropped on a feature in any view. tire folders. In addition, we provide facilities of navigating the source tree by feature. This way, developers can get a quick overview of how features are distributed and navigate between them. To scale color usage to large software systems, we provide an as-needed mapping of colors to features. By default, each feature is assigned a shade of gray. That is, we see different shades as background colors and in the bar chart. Shades of gray are sufficient to recognize that there is some feature code and that different features are involved. To analyze a feature (or small set of features) in more detail, the developer assigns more distinguishable colors to individual features per drag and drop. This reflects that developers typically work with only few features at a time, whereas the major part of the source code does not need to be highlighted. This way, background-color usage scales to large software projects with several hundred features. This is a major ad- vantage of FeatureCommander compared to existing color concepts, for example as implemented in CIDE [4]. To evaluate whether the implemented background-color concepts work on a large scale, we conducted a controlled experiment based on Xenomai 1 , a large program with over 160,000 lines of code and over 300 features [2]. We found that background colors speed up the comprehension process 1 http://www.xenomai.org This is the authors version of the paper and intended for personal use only. Any other use may violate the ACM copyright.