Virtual Separation of Concerns: Toward Preprocessors 2.0

Virtual Separation of Concerns: Toward Preprocessors 2.0

Virtual Separation of Concerns: Toward Preprocessors 2.0 Dissertation zur Erlangung des akademischen Grades Doktoringenieur (Dr.-Ing.) angenommen durch die Fakultät für Informatik der Otto-von-Guericke-Universität Magdeburg von Dipl.-Wirt.-Inform. Christian Kästner geb. am 21. September 1982 in Schwedt/Oder Gutachter: Prof. Dr. Gunter Saake Prof. Don Batory, Ph.D. Prof. Krzysztof Czarnecki, Ph.D. Promotionskolloquium: Magdeburg, den 31. Mai 2010 Kästner, Christian: Virtual Separation of Concerns: Toward Preprocessors 2.0 Dissertation, Otto-von-Guericke-Universität Magdeburg, 2010. Abstract Conditional compilation with preprocessors such as cpp is a simple but effective means to implement variability. By annotating code fragments with #ifdef and #endif directives, different program variants with or without these annotated frag- ments can be created, which can be used (among others) to implement software product lines. Although, such annotation-based approaches are frequently used in practice, researchers often criticize them for their negative effect on code quality and maintainability. In contrast to modularized implementations such as compo- nents or aspects, annotation-based implementations typically neglect separation of concerns, can entirely obfuscate the source code, and are prone to introduce subtle errors. Our goal is to rehabilitate annotation-based approaches by showing how tool support can address these problems. With views, we emulate modularity; with a visual representation of annotations, we reduce source code obfuscation and in- crease program comprehension; and with disciplined annotations and a product- line–aware type system, we prevent or detect syntax and type errors in the entire software product line. At the same time we emphasize unique benefits of annota- tions, including simplicity, expressiveness, and being language independent. All in all, we provide tool-based separation of concerns without necessarily dividing source code into physically separated modules; we name this approach virtual separation of concerns. We argue that with these improvements over contemporary preprocessors, vir- tual separation of concerns can compete with modularized implementation mech- anisms. Despite our focus on annotation-based approaches, we do intend not give a definite answer on how to implement software product lines. Modular implementations and annotation-based implementations both have their advan- tages; we even present an integration and migration path between them. Our goal is to rehabilitate preprocessors and show that they are not a lost cause as many researchers think. On the contrary, we argue that – with the presented improve- ments – annotation-based approaches are a serious alternative for product-line implementation. iii Acknowledgments Finishing this dissertation would have been impossible without the help of many persons. First and foremost, I would like to thank Sven Apel with whom I worked together closely for the last three years. Sven supported me since my Master’s thesis and guided my research in many ways. Despite communicating mostly via email and telephone due to different locations, our collaborations were reliable, efficient, and productive, and I highly value his feedback. Sven guided me to interesting research questions, for example, regarding type checking, formalisms, and empirical evaluation. Often, we have addressed the same problem from differ- ent perspectives (roughly speaking, he as proponent of compositional approaches, me as proponent of annotative approaches) which repeatedly lead to interesting insights and trade-offs, many of which are discussed in this thesis. Second, Don Batory has constantly supported and challenged me. When I vis- ited him at the University of Texas at Austin for my Master’s thesis and observed several problems in my aspect-oriented decomposition of Berkeley DB, he chal- lenged me to look for better variability mechanisms and consistently encouraged me to pursue my early ideas with colors and annotations in CIDE (which went into quite a different direction from his and my work up to that time). Many ideas discussed in this thesis, including visual representation, views, and type checking, emerged in an early raw form already during my visit in his group. Since then, he provided support and ideas for many research topics. It is always a pleasure to work with Don. Third, I want to thank Gunter Saake who gave me the opportunity to pursue a PhD in his group. Gunter has provided an excellent environment for research and has guaranteed me entire freedom. His support for our lecture on product- line implementation for graduate students laid the ground for many interesting projects and young scientists with interest in software product lines. His group proved to be an excellent place for academic development and collaboration. Fourth, I like to express my deepest gratitude to all my colleagues and stu- dents with whom I had the pleasure to collaborate and discuss, including Danilo Beuche, Alexander Dreiling, Janet Feigenspan, Armin Größlinger, Sebastian Gün- ther, Florian Heidenreich, Andy Kenner, Martin Kuhlemann, Thomas Leich, Chris- tian Lengauer, Jörg Liebig, Andreas Lübcke, Mario Pukall, Syed Saif ur Rah- man, Marko Rosenmüller, Malte Rosenthal, Sandro Schulze, Norbert Siegmund, Friedrich Steimann, Sagar Sunkle, Thomas Thüm, and Salvador Trujillo. Of them, I would specifically like to address a special thanks to Martin, Janet, Thomas T., v and Jörg for their great collaboration on significant parts of this thesis; to Marko and Norbert for their support in my ongoing struggle with C and C++; to Armin and Malte for their patient help with Haskell; and to Thomas L. for his contin- uous support with the capabilities on an industrial partner. Last but not least, I gratefully thank my family and friends for their ongoing support far beyond this thesis. vi Contents Contents vii List of Figures xi List of Tables xiii List of Abbreviations xv 1. Introduction 1 1.1. Contribution . .4 1.2. Outline . .5 2. Background 7 2.1. Software product lines . .7 2.2. Domain engineering and application engineering . .8 2.3. Variability modeling . 10 2.4. Separation of concerns . 13 3. Software product line implementation 17 3.1. Compositional approaches . 18 3.1.1. Modularity . 19 3.1.2. Traceability . 21 3.1.3. Language support for variability . 22 3.1.4. Coarse granularity . 22 3.1.5. The optional feature problem . 26 3.1.6. Difficult adoption . 28 3.1.7. Case study: Berkeley DB . 29 3.2. Annotative approaches . 33 3.2.1. Separation of concerns . 35 3.2.2. Obfuscation . 36 3.2.3. Error proneness . 39 3.2.4. Simple and uniform programming model . 40 3.2.5. Fine granularity . 41 3.2.6. Variability despite feature interactions . 41 3.3. Other approaches . 41 vii CONTENTS 3.4. Summary, perspective, and goals . 44 4. Views and visual representation 47 4.1. Integrating a feature model . 47 4.1.1. Implementation . 48 4.1.2. Discussion . 50 4.2. Views . 51 4.2.1. View on a feature . 52 4.2.2. View on a variant . 54 4.2.3. Design decisions . 55 4.2.4. Implementation . 57 4.3. Visual representation . 57 4.3.1. Background colors . 59 4.3.2. Scalability of colors . 61 4.4. Experimental evaluation . 64 4.4.1. Experiment planning . 67 4.4.2. Results . 70 4.4.3. Interpretation . 72 4.5. Related work . 74 4.6. Summary . 79 5. Error detection 81 5.1. Taxonomy . 81 5.2. Disciplined annotations . 84 5.2.1. Basic concept . 84 5.2.2. Detecting disciplined annotations . 85 5.2.3. From string removal to AST transformations . 87 5.2.4. Wrappers . 90 5.2.5. Flexibility vs. safety . 91 5.2.6. Evaluation . 93 5.3. Product-line–aware type system . 99 5.3.1. Type errors in software product lines . 99 5.3.2. Desired properties . 102 5.3.3. Colored Featherweight Java (CFJ) . 103 5.3.4. Alternative features . 119 5.3.5. Beyond Featherweight Java . 124 5.3.6. Evaluation . 126 5.4. Related work . 132 5.5. Summary . 141 viii CONTENTS 6. Comparison and integration 143 6.1. Comparison . 143 6.1.1. Modularity . 143 6.1.2. Traceability . 147 6.1.3. Language integration . 147 6.1.4. Errors . 148 6.1.5. Granularity . 150 6.1.6. Optional feature problem . 150 6.1.7. Uniformity . 151 6.1.8. Adoption . 152 6.2. Perspective: Integrating compositional and annotative approaches . 154 6.2.1. Spectrum between physical and virtual separation . 154 6.2.2. Benefits . 156 6.2.3. Automated refactoring . 158 6.3. Summary . 165 7. Conclusion and future work 167 A. List of case studies 173 A.1. Case studies developed in CIDE . 173 A.2. Forty C programs . 181 Bibliography 183 ix List of Figures 2.1. An (idealized) overview of domain engineering and application en- gineering. .9 2.2. Feature-diagram example of a small database product line. 11 3.1. Two compositional implementations of a stack example with three features. 20 3.2. Example of a fine-grained extensions. 23 3.3. Implementation of fine-grained extensions with Jak. 25 3.4. Modularization of interacting features. 27 3.5. Additional modules to modularize feature interactions. 28 3.6. Code excerpt of Berkeley DB. 34 3.7. Example of scattered configuration knowledge in Vim......... 36 3.8. Java code obfuscated by fine-grained annotations with cpp....... 37 3.9. Preprocessor directives in the code of Femto OS. 38 3.10. Adapted code excerpt of Berkeley DB, with syntax error in variants without Have_Queue ........................... 40 3.11. Preprocessor-based implementation of the expression problem (ex- cerpt). 42 4.1. Annotations in CIDE based on a feature model. 49 4.2. Views on a annotation-based implementation of the expression prob- lem ...................................... 53 4.3. View on feature Transactions in the file structure of Berkeley DB . 58 4.4. Annotations represented by a background color instead of textual annotations. 59 4.5. Representing nested annotations with background colors.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    223 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us