Generative Programming

Total Page:16

File Type:pdf, Size:1020Kb

Generative Programming Generative Programming Principles and Techniques of Software Engineering Based on Automated Configuration and Fragment-Based Component Models by Dipl.-Inf. Krzysztof Czarnecki A dissertation submitted in partial fulfillment of the requirements for the degree of Doktor-Ingenieur Department of Computer Science and Automation Technical University of Ilmenau October 1998 Supervisory Committee: Universitair Hoofd Docent Dr. Mehmet Aksit, University of Twente, The Netherlands Prof. Dr. Ulrich W. Eisenecker, FH Heidelberg, Germany Prof. Dr.-Ing. habil. Dietrich Reschke (Chairperson of Supervisory Committee), TU Ilmenau, Germany Oral defense held on August 9, 1999 iii Abstract Current object-oriented (OO) and component technologies suffer from several problems such as the lack of analysis and design methods for the development for reuse, lack of effective techniques for dealing with many variants of components, loss of design knowledge due to the semantic gap between domain abstractions and programming language features, and runtime performance penalties for clean and flexible design. This thesis proposes Generative Programming (GP) as a comprehensive software development paradigm to achieving high intentionality, reusability, and adaptability without the need to compromise the runtime performance and computing resources of the produced software. In the area of analysis and design for GP, we investigate Domain Engineering (DE) methods and their integration with OO analysis and design (OOA/D) methods. The main difference between DE methods and OOA/D methods is that the first are geared towards developing whole families of systems while the latter focus on developing single systems. We identify feature modeling as the main contribution of DE to OOA/D. Feature models represent the configurability aspect of reusable software at an abstract level, i.e. without committing to any particular implementation technique such as inheritance, aggregation, or parameterized classes. We give a precise and extended formulation of the feature diagram notation and investigate the relationship between feature modeling, OO modeling and Aspect- Oriented Programming. In the area of implementation for GP, we study various metaprogramming technologies. We identify modularly extensible programming environments as the ideal programming platform for GP, which allows implementing domain-specific optimizations, domain-specific displaying and editing, domain-specific debugging and code analysis, new composition mechanisms, etc., in a scalable way. We also propose new implementation techniques such as configuration generators based on mixin models with automatic configuration and configuration repositories and make several contribution to template metaprogramming. Based on the analysis of the areas mentioned above, we propose a new Domain Engineering method for the development of algorithmic reusable libraries (DEMRAL), which integrates various DE, OO, and AOP concepts. We validate the method by applying it to the domain of matrix computations, which results in the development of the Generative Matrix Computation Library (GMCL). We provide two implementation GMCL, one using generative programming techniques in C++ and another one in Intentional Programming (an modularly extendible programming environment). In addition to validating the usefulness of DEMRAL, the GMCL case study provides a concrete comparison of two generative implementation technologies. The C++ implementation of the matrix component (which is a part of C++ GMCL) comprises only 7500 lines of C++ code, but it is capable of generating more than 1840 different kinds of matrices. Despite the large number of provided matrix variants, the performance of the generated code is comparable with the performance of manually coded variants. The application of template metaprogramming allowed a highly intentional library API and a highly efficient library implementation at the same time. The implementation of GMCL within the Intentional Programming system (IP) demonstrates the advantages of IP, particularly in the area of debugging and displaying. iv Acknowledgements First I would like to thank my wife Katja for her love, encouragement, and patient support. I am also grateful to my parents for giving me best of their life and the necessary education. I would like to thank Dietrich Reschke, the chairman of supervisory committee for his invaluable advice, excitement, and generous support for this work. I am very grateful to Ulrich Eisenecker, one of the supervisors of this thesis, for encouraging me to work in this area, for giving me his professional guidance and advice throughout all phases of this work, for sharing many inspiring thoughts during our close research cooperation on Generative Programming, and for carefully reading and commenting hundreds of pages of all my professional writing. I also would like to express special thanks to Mehmet Aksit for his valuable suggestions and encouragement and for kindly accepting to be one of the supervisors of this thesis. Many thanks also go to Reinhold Schönefeld, who supervised the initial phase of my doctorial research. During my research on this thesis I had the pleasure to supervise two brilliant students Tobias Neubert and Johannes Knaupp. Tobias implemented the full version of the generative C++ matrix component and is also responsible for many improvements of the configuration generator concept. Johannes contributed several improvements of the template metaprogramming techniques, extended the C++ matrix component, and developed a configuration generator for the family of LU matrix factorization algorithms (work directly building on this thesis). This thesis would not have been finished without the generous support and encouragement of my friends and colleagues at Daimler-Benz AG Research and Technology in Ulm, especially my managers Wolfgang Hanika and Roland Trauter and my colleagues from the OSVA project team Wolfgang Köpf and Michael Jungmann. Special thanks go to Charles Simonyi, Greg Shaw, and the entire Intentional Programming (IP) team at Microsoft Research for patiently teaching me in the ways of IP and helping me with the IP implementation of the matrix case study during my research visit in January 1998. I would also like to thank Gregor Kiczales, Crista Lopes, John Lamping, and other members of the Aspect-Oriented Programming (AOP) team at Xerox PARC for explaining to me the AOP ideas, providing me with an early version of AspectJ, and sharing many stimulating thoughts that lead to the development of Dynamic Cool during my research visit in October/November 1997. I am grateful to Mark Simos who shared with me both his invaluable insights into the area of Domain Engineering and his excitement for this area. I also would like to express my thanks to Don Batory for the advice and positive feedback he gave me. Attending his tutorial on generators at ICSR’96 provided me with important motivation for doing this research. Many thanks also go to Karl Lieberherr for his positive feedback and the many stimulating discussions we had. During the Dagstuhl seminar on “Generic Programming” in March 1998, Ulrich Eisenecker, Robert Glück, Daveed Vandevoorde, and Todd Veldhuizen and I started an informal working group on Active Libraries. Our numerous discussions at Dagstuhl and later per e-mail greatly influenced the last steps of this work. I would like to thank all of the group members. During several conferences, I had the pleasure to meet many interesting people from the reuse community and the object-oriented community who gave me useful feedback and shared with me their ideas. My thanks go to Ted Biggerstaff, Ulrich Breymann, Mike VanHilst, Sholom Cohen and the participants of the WISR’97 working group on Domain Engineering and Object Technology, Andrew Lumsdaine, Satoshi Matsuoka, David Quinlan, Jeremy Siek, Yannis Smaragdakis, Douglas Smith, Partick Steyart, Bruce Weide, and many others. I also would like to thank many other researchers, including Ira Baxter, John Favaro, Martin Griss, and Jim Neighbors, who played important roles in helping me form my ideas. v In addition to the supervisors, several other researchers, including William Harrison, Gregor Kiczales, Karl Lieberherr, Harold Ossher, Greg Shaw, Mark Simos, and Peri Tarr gave me invaluable comments on various chapters of earlier drafts of this thesis. I also would like to thank Bogdan Franczyk and Witold Wendrowski for their professional support and friendship. Funding for this work has been provided by Daimler-Benz AG and German Federal Ministry of Education, Science, Research and Technology (BMBF) through the OSVA project. Knowing that this list is certainly not exhaustive, I hope that those who I have forgotten to mention will forgive me. vi Overview Part I Setting the Stage_________________________________________ 1 Chapter 1 What Is this Thesis About?____________________________ 3 Chapter 2 Conceptual Modeling _______________________________ 17 Part II Analysis and Design Methods and Techniques________________ 31 Chapter 3 Domain Engineering ________________________________ 33 Chapter 4 Domain Engineering and Object-Oriented Analysis and Design66 Chapter 5 Feature Modeling __________________________________ 83 Part III Implementation Technologies __________________________ 117 Chapter 6 Generators _______________________________________ 119 Chapter 7 Aspect-Oriented Decomposition and Composition _______ 181 Chapter 8 Static Metaprogramming in C++______________________ 241 Part IV Putting
Recommended publications
  • Concurrency Patterns for Easier Robotic Coordination
    Concurrency Patterns for Easier Robotic Coordination Andrey Rusakov∗ Jiwon Shin∗ Bertrand Meyer∗† ∗Chair of Software Engineering, Department of Computer Science, ETH Zurich,¨ Switzerland †Software Engineering Lab, Innopolis University, Kazan, Russia fandrey.rusakov, jiwon.shin, [email protected] Abstract— Software design patterns are reusable solutions to Guarded suspension – are chosen for their concurrent nature, commonly occurring problems in software development. Grow- applicability to robotic coordination, and evidence of use ing complexity of robotics software increases the importance of in existing robotics frameworks. The paper aims to help applying proper software engineering principles and methods such as design patterns to robotics. Concurrency design patterns programmers who are not yet experts in concurrency to are particularly interesting to robotics because robots often have identify and then to apply one of the common concurrency- many components that can operate in parallel. However, there based solutions for their applications on robotic coordination. has not yet been any established set of reusable concurrency The rest of the paper is organized as follows: After design patterns for robotics. For this purpose, we choose six presenting related work in Section II, it proceeds with a known concurrency patterns – Future, Periodic timer, Invoke later, Active object, Cooperative cancellation, and Guarded sus- general description of concurrency approach for robotics pension. We demonstrate how these patterns could be used for in Section III. Then the paper presents and describes in solving common robotic coordination tasks. We also discuss detail a number of concurrency patterns related to robotic advantages and disadvantages of the patterns and how existing coordination in Section IV.
    [Show full text]
  • The Evolution of Control Architectures Towards Next Generation
    Department of Electronic and Electrical Engineering University College London University of London T h e Ev o l u t io n o f C o n t r o l A rchitectures T o w a r d s N ext G e n e r a t io n N e t w o r k s By Christos Solomonides BEng(Hons), MRes(Distinction) 7 September 2001 A thesis submitted to the University o f London for the Ph.D. in Electronic and Electrical Engineering ProQuest Number: U643054 All rights reserved INFORMATION TO ALL USERS The quality of this reproduction is dependent upon the quality of the copy submitted. In the unlikely event that the author did not send a complete manuscript and there are missing pages, these will be noted. Also, if material had to be removed, a note will indicate the deletion. uest. ProQuest U643054 Published by ProQuest LLC(2016). Copyright of the Dissertation is held by the Author. All rights reserved. This work is protected against unauthorized copying under Title 17, United States Code. Microform Edition © ProQuest LLC. ProQuest LLC 789 East Eisenhower Parkway P.O. Box 1346 Ann Arbor, Ml 48106-1346 A b s t r a c t This thesis describes the evolution of control architectures and network intelligence towards next generation telecommunications networks. Network intelligence is a term given to the group of architectures that provide enhanced control services. Network intelligence is provided through the control plane, which is responsible for the establishment, operation and termination of calls and connections. The work focuses on examining the way in which network intelligence has been provided in the traditional telecommunications environment and in a converging environment.
    [Show full text]
  • Towards Software Development
    WDS'05 Proceedings of Contributed Papers, Part I, 36–40, 2005. ISBN 80-86732-59-2 © MATFYZPRESS Towards Software Development P. Panuška Charles University, Faculty of Mathematics and Physics, Prague, Czech Republic. Abstract. New approaches to software development have evolved recently. Among these belong not only development tools like IDEs, debuggers and Visual modelling tools but also new, modern1 styles of programming including Language Oriented Programming, Aspect Oriented Programming, Generative Programming, Generic Programming, Intentional Programming and others. This paper brings an overview of several methods that may help in software development. Introduction An amazing progress in software algorithms, hardware, GUI and group of problems we can solve has been made within last 40 years. Unfortunately, the same we cannot say about the way the software is actually made. The source code of programs has not changed and editors we use to edit, create and maintain computer programs still work with the source code mainly as with a piece of text. This is not the only relic remaining in current software development procedures. Software development is one of human tasks where most of the job must be done by people. Human resources belong to the most expensive, most limiting and most unreliable ones. People tend to make more mistakes than any kind of automatic machines. They must be trained, may strike, may get ill, need holidays, lunch breaks, baby breaks, etc. Universities can not produce an unlimited number of software engineers. Even if the number of technical colleges were doubled, it would not lead in double amount of high-quality programmers.
    [Show full text]
  • Bibliography on Transformation Systems (PDF Format)
    Transformation Technology Bibliography, 1998 Ira Baxter Semantic Designs 12636 Research Blvd, Suite C214 Austin, Texas 78759 [email protected] The fundamental ideas for transformation systems are: domains where/when does one define a notation for a problem area; semantics how the meaning of a notation is defined; implementation what it means for one spec fragment to “implement” another; and control how to choose among possible implementations. The following references describe various ways of implementing one or more of the above ideas. Unfortunately, there aren't any easy, obviously good articles or books on the topic, and there is a lot of exotic technology. I recommend: the Agresti book (a number of short papers) for overview, the Feather survey paper for conciseness and broadness. These are the minimum required reading to get a sense of the field. The Partsch book is excellent for a view of transformational development using wide spectrum languages, but fails to address domains and control. The Turski book is very good for some key theory, but you have to be determined to wade through it. Bibliography [AGRESTI86] What are the New Paradigms?, William W. Agresti, New Paradigms for Software Development, William W. Agresti, IEEE Press, 1986, ISBN 0-8186-0707-6. [ALLEMANG90] Understandings Programs as Devices, Dean T. Allemang, Ph.D. Thesis, Computer Science Department, Ohio State University, Columbus, Ohio, 1990. [ALLEN90] Readings in Planning, James Allen, James Hendler and Austin Tate, Morgan Kaufmann, San Mateo, California,1990, ISBN 1-55860-130-9. [ASTESIANO87] An Introduction to ASL, Egidio Astesiano and Martin Wirsing, pp. 343-365, Program Specification and Transformation, L.
    [Show full text]
  • Components and Generative Programming
    Components and Generative Programming Krzysztof Czarnecki1 and Ulrich W. Eisenecker2 1DaimlerChrysler AG Research and Technology, Ulm, Germany [email protected] 2University of Applied Sciences Heidelberg, Germany [email protected] Abstract. This paper is about a paradigm shift from the current practice of manually searching for and adapting components and their manual assembly to Generative Programming, which is the automatic selection and assembly of components on demand. First, we argue that the current OO technology does not support reuse and configurability in an effective way. Then we show how a system family approach can aid in defining reusable components. Finally, we describe how to automate the assembly of components based on configuration knowledge. We compare this paradigm shift to the introduction of interchangeable parts and automated assembly lines in the automobile industry. We also illustrate the steps necessary to develop a product line using a simple example of a car product line. We present the feature model of the product line, develop a layered architecture for it, and automate the assembly of the components using a generator. We also discuss some design issues, applicability of the approach, and future development. 1 From Handcrafting to an Automated Assembly Line This paper is about a paradigm shift from the current practice of manually searching for and adapting components and their manual assembly to Generative Programming, which is the automatic selection and assembly of components on demand. This paradigm shift takes two steps. First, we need to move our focus from engineering single systems to engineering families of systems—this will allow us to come up with the “right” implementation components.
    [Show full text]
  • ESWP3 - Embedded Software Principles, Patterns and Procedures Release 1.0
    ESWP3 - Embedded Software Principles, Patterns and Procedures Release 1.0 ESWP3 contributors September 24, 2015 Contents 1 Human Relation Patterns 3 1.1 Categorization of human relation patterns................................3 2 Principles 5 2.1 Categorization of principles.......................................5 2.2 All principles in alphabetic order....................................5 3 Build Patterns 7 3.1 Categorization of build patterns.....................................7 3.2 All build patterns in alphabetic order..................................8 4 Release Antipatterns 11 5 Requirement Patterns 13 5.1 Standardized Textual Specification Pattern............................... 13 5.2 Perform Manual Review Pattern..................................... 13 6 Design Patterns 15 6.1 Categorization of “design” patterns................................... 15 6.2 Pattern Selection Procedure....................................... 21 6.3 Legend to the design pattern sections.................................. 21 6.4 All design patterns in alphabetic order.................................. 21 7 Idioms in C 29 7.1 Classification of idioms......................................... 29 7.2 Add the name space........................................... 29 7.3 Constants to the left........................................... 29 7.4 Magic numbers as variables....................................... 30 7.5 Namend parameters........................................... 30 7.6 Sizeof to variables............................................ 30 8 Unit Test Patterns
    [Show full text]
  • Reliable and Automatic Composition of Language Extensions to C
    Reliable and Automatic Composition of Language Extensions to C The ableC Extensible Language Framework 98 TED KAMINSKI, University of Minnesota, USA LUCAS KRAMER, University of Minnesota, USA TRAVIS CARLSON, University of Minnesota, USA ERIC VAN WYK, University of Minnesota, USA This paper describes an extensible language framework, ableC, that allows programmers to import new, domain-specific, independently-developed language features into their programming language, in thiscase C. Most importantly, this framework ensures that the language extensions will automatically compose to form a working translator that does not terminate abnormally. This is possible due to two modular analyses that extension developers can apply to their language extension to check its composability. Specifically, these ensure that the composed concrete syntax specification is non-ambiguous and the composed attribute grammar specifying the semantics is well-defined. This assurance and the expressiveness of the supported extensions is a distinguishing characteristic of the approach. The paper describes a number of techniques for specifying a host language, in this case C at the C11 standard, to make it more amenable to language extension. These include techniques that make additional extensions pass these modular analyses, refactorings of the host language to support a wider range of extensions, and the addition of semantic extension points to support, for example, operator overloading and non-local code transformations. CCS Concepts: • Software and its engineering → Extensible languages; Translator writing systems and compiler generators; Additional Key Words and Phrases: extensible compiler frameworks, domain specific languages, language composition, attribute grammars, context-aware scanning ACM Reference Format: Ted Kaminski, Lucas Kramer, Travis Carlson, and Eric Van Wyk.
    [Show full text]
  • Notes on Postmodern Programming
    Notes on Postmodern Programming James Noble, Robert Biddle Computer Science, Victoria University of Wellington, New Zealand. robert,kjx ¡ @mcs.vuw.ac.nz March 23, 2002 0 Manifesto The ultimate goal of all computer science is the program. The performance of programs was once the noblest function of computer science, and computer science was indispensable to great programs. Today, programming and com- puter science exist in complacent isolation, and can only be rescued by the conscious co-operation and collaboration of all programmers. The universities were unable to produce this unity; and how indeed, should they have done so, since creativity cannot be taught? Designers, programmers and engineers must once again come to know and comprehend the composite character of a program, both as an entity and in terms of its various parts. Then their work will be filled with that true software spirit which, as “theory of computing”, it has lost. Universities must return to programming. The worlds of the formal methods and algorithm analysis, consisting only of logic and mathematics, must become once again a world in which things are built. If the young person who rejoices in creative activity now begins his career as in the older days by learning to program, then the unproductive “scientist” will no longer be condemned to inadequate science, for their skills will be preserved for the programming in which they can achieve great things. Designers, programmers, engineers, we must all return to programming! There is no essential difference between the computer scientist and the pro- grammer. The computer scientist is an exalted programmer.
    [Show full text]
  • Generative Programming Methods Tools and Applications
    Generative Programming Methods Tools And Applications Dewy-eyed and Serbonian Tremain forsook, but Dirk actuarially focalise her Bagley. Hurried and conirostral Collin never left his mastigophorans! Louie never long any tout streaks unlively, is Regan surly and salutary enough? Specific isbn edition is less, methods and generative programming tools applications. To illustrate, consider again the previous example of implementing different error handling policies in a certain piece of code. Once developed, these common components would form the basis of each gateway system. Please try after some time. Static Interactions between Components. Unix is in some solutions lacking in different delivery, comparative study and applications and build complete applications. Specifically, we will learn about loose coupling between structure and behavior which leads to adaptiveness. The object code that is generated by the extended compiler encodes both the behaviour defined by the base program and the aspect defined by the aspect program. The raw dblp metadata in XML files as stable, persistent releases. Engineering possible and allows to expand the generator when necessary. System specific applications and products with applicability to the product family can be added to the common set of assets for other systems to reuse. You want to start with an instance of the code. In the future, concepts of ubiquitous communications infrastructure, dynamic service discovery, and mobile agents will enable loosely coupled systems to collaborate to establish objectives and achieve broad mission goals. There is a natural resistance to change, whether organizational or process. However, standards alone will not be sufficient to solve the problem. Comments on this work from the members of this community are welcome and appreciated.
    [Show full text]
  • Executive Summary: Balking Design Patterns by Drew Goldberg
    Executive Summary: Balking Design Patterns By Drew Goldberg Balking Patterns are used to prevent an object from executing certain code if it is an incomplete or inappropriate state. These Design Patterns include: The Balking Pattern, The Guarded Suspension, and The Double-Checked Locking Pattern. These patterns seem to have arisen when JVMs were slower and synchronization wasn't as well understood as it is today. These patterns have appeared become somewhat antiquated as JVMs improved, newer design pattern(s) were introduced, and the increased use of functional programming language's immutable/persistent data structures help reduce the complexities of concurrency's implementation and maintenance. Still it is nice to see what was used in the past inorder to get a better perspective of today's concurrency techniques. Balking - Design Patterns Dealing with Incomplete and Incorrect States By Drew Goldberg What are balking patterns? ● Balking - If an object’s method is invoked when the object is in an inappropriate state, then the method will return without doing anything. Balking Design Patterns: ● Balking Design Pattern ● Guarded Suspension ● Double Checked Locking Reference: http://www.mindspring.com/~mgrand/pattern_synopses.htm#Balking Balking Pattern: Intro ● This software design pattern is used to invoke an action on an object only when the object is in a particular state. ● Objects that use this pattern are generally only in a state that is prone to balking temporarily but for an unknown amount of time reference: http://en.wikipedia.org/wiki/Balking_pattern Balking Pattern: Implementation public class Example { private boolean jobInProgress = false; public void job() { synchronized(this) { If the boolean instance variable if (jobInProgress) { jobInProgress is set to false, then return; the job() will return without having } jobInProgress = true; executed any commands and } therefore keeping the object's // Code to execute job goes here state the same.
    [Show full text]
  • Guide for Caadria Conference Authors
    A CASE FOR ARCHITECTURAL COMPUTING Computing Using Architectural Constructs GANAPATHY MAHALINGAM North Dakota State University, U.S.A. [email protected] Abstract. This paper is about the potential of architectural computing. Architectural computing is defined as computing that is done with computational structures that are based on architectural forms. An analysis of works of architecture reveals the embedded forms in the works of architecture. A uniform, connections-based representation of these architectural forms allows us to derive computational structures from them. These computational structures form the basis of architectural computing. In this paper a case is made for architectural computing, ideas are provided for how it could be done, and the benefits of architectural computing are briefly explored. Keywords. Architectural computing: architectural programming language; intentional programming; connections-based paradigm. 1. Introduction Researchers in the field of computer-aided architectural design have pondered the computability of design for the past 3 to 4 decades. While this inquiry may seem moot now, given that most design activities can be performed on the computer using various pieces of software, it has masked what can now be considered as a unique form of computing, architectural computing. Claude Shannon (1937), in his influential master’s thesis, A Symbolic Analysis of Relay and Switching Circuits, literally founded modern digital computing by integrating Boolean algebra, binary arithmetic and electromechanical relays into an effective device to perform computations. What if we now recast the inherent devices of architecture as effective machines? Can we build architectural computers from them? What would these computers do and what would be their unique characteristics? What if we derive an architectural programming language from the operations of architectural design? Not too long ago, Charles Simonyi (1995) hailed the death of computer languages and the birth of intentional programming.
    [Show full text]
  • A Browser for Incremental Programming
    Portland State University PDXScholar Computer Science Faculty Publications and Presentations Computer Science 9-2003 A Browser for Incremental Programming Andrew P. Black Portland State University, [email protected] Follow this and additional works at: https://pdxscholar.library.pdx.edu/compsci_fac Part of the Programming Languages and Compilers Commons, and the Software Engineering Commons Let us know how access to this document benefits ou.y Citation Details Schärli, Nathanael, and Andrew P. Black. "A browser for incremental programming." Computer Languages, Systems & Structures 30.1 (2004): 79-95. This Post-Print is brought to you for free and open access. It has been accepted for inclusion in Computer Science Faculty Publications and Presentations by an authorized administrator of PDXScholar. Please contact us if we can make this document more accessible: [email protected]. A Browser for Incremental Programming Nathanael Scharli¨ a,∗ Andrew P. Black b aSoftware Composition Group, University of Bern, Switzerland bOGI School of Science & Engineering, Oregon Health & Science University, USA Abstract Much of the elegance and power of Smalltalk comes from its programming environment and tools. First introduced more than 20 years ago, the Smalltalk browser enables programmers to “home in” on particular methods using a hierarchy of manually-defined classifications. By its nature, this clas- sification scheme says a lot about the desired state of the code, but little about the actual state of the code as it is being developed. We have extended the Smalltalk browser with dynamically computed virtual categories that dramatically improve the browser’s support for incremental programming. We illustrate these improvements by example, and describe the algorithms used to compute the virtual categories efficiently.
    [Show full text]