Generative Programming: Methods, Tools, and Applications

Krysztof Czarnecki / Ulrich Eisenecker  
Total pages
June 2000

Product detail

Product Price CHF Available  
Generative Programming: Methods, Tools, and Applications


Generative Programming (GP) offers the promise of moving from "one-of-a-kind" software systems to the semi-automated manufacture of wide varieties of software -- essentially, an assembly line for software systems. GP's goal is to model software system families and build software modules such that, given particular requirements specs, highly customized and optimized intermediate or end products can be constructed on demand. This is the first book to cover Generative Programming in depth. The authors, leaders in their field, introduce the two-stage GP development cycle: one stage for designing and implementing a generative domain model, and another for using the model to build concrete systems. They review key differences between generative modeling and processes used for "one-of-a-kind" systems. Next, they introduce key GP concepts such as feature models, and demonstrate "generic programming" techniques for creating components which lend themselves to easy combination and reuse. The book also introduces Aspect Oriented Programming, which allows developers to solve key recurring problems in traditional O-O development; and presents metaprogramming techniques for building powerful program generators. Three detailed case studies demonstrate the entire generative development cycle, from analysis to implementation.

Table of Contents

1. What Is This Book About?

From Handcrafting to Automated Assembly Lines.

Generative Programming.

Benefits and Applicability.


2. Domain Engineering.

Why Is This Chapter Worth Reading?

What Is Domain Engineering?

Domain Analysis.

Domain Design and Domain Implementation.

Application Engineering.

Product-Line Practices.

Key Domain Engineering Concepts.


Domain Scope and Scoping.

Relationships between Domains.

Features and Feature Models.

Method Tailoring and Specialization.

Survey of Domain Analysis and Domain Engineering Methods.

Feature-Oriented Domain Analysis (FODA).

Organization Domain Modeling (ODM).



Domain Analysis and Reuse Environment (DARE).

Domain-Specific Software Architecture (DSSA) Approach.

Algebraic Approach.

Other Approaches.

Domain Engineering and Related Approaches.

Historical Notes.


3. Domain Engineering and Object-Oriented Analysis and Design.

Why Is This Chapter Worth Reading?

OO Technology and Reuse.

Solution Space.

Problem Space.

Relationship between Domain Engineering and Object-Oriented Analysis and Design (OOA/D) Methods.

Aspects of Integrating Domain Engineering and OOA/D Methods.

Horizontal versus Vertical Methods.

Selected Methods.

Rational Unified Process.


Reuse-Driven Software Engineering Business (RSEB).


Domain Engineering Method for Reusable Algorithmic Libraries (DEMRAL).

4. Feature Modeling.

Why Is This Chapter Worth Reading?

Features Revisited.

Feature Modeling.

Feature Models.

Feature Diagrams.

Other Infon-Nation Associated with Feature Diagrams in a Feature Model.

Assigning Priorities to Variable Features.

Availability Sites, Binding Sites, and Binding Modes.

Relationship between Feature Diagrams and Other Modeling Notations and Implementation Techniques.

Single Inheritance.

Multiple Inheritance.

Parameterized Inheritance.

Static Parameterization.

Dynamic Parameterization.

Implementing Constraints.

Tool Support for Feature Models.

Frequently Asked Questions about Feature Diagrams.

Feature Modeling Process.

How to Find Features.

Role of Variability in Modeling.

5. The Process of Generative Programming.

Why Is This Chapter Worth Reading?

Generative Domain Models.

Main Development Steps in Generative Programming.

Adapting Domain Engineering for Generative Programming.

Domain-Specific Languages.

DEMRAL: Example of a Domain Engineering Method for Generative Programming.

Outline of DEMRAL.

Domain Analysis.

Domain Definition.

Domain Modeling.

Domain Design.

Scope Domain Model for Implementation.

Identify Packages.

Develop Target Architectures and Identify the Implementation Components.

Identify User DSLs.

Identify Interactions between DSLs.

Specify DSLs and Their Translation.

Configuration DSLs.

Expression DSLs.

Domain Implementation.


6. Generic Programming.

Why Is This Chapter Worth Reading?

What Is Generic Programming?

Generic versus Generative Programming.

Generic Parameters.

Parametric versus Subtype Polymorphism.

Genericity in Java.

Bounded versus Unbounded Polymorphism.

A Fresh Look at Polymorphism.

Parameterized Components.

Parameterized Programming.

Types, Interfaces, and Specifications.


Vertical and Horizontal Parameters.

Module Expressions.

C++ Standard Template Library.


Freestanding Functions versus Member Functions.

Generic Methodology.

Historical Notes.

7. Component-Oriented Template-Based C++ Programming Techniques.

Why Is This Chapter Worth Reading?

Types of System Configuration.

C++ Support for Dynamic Configuration.

C++ Support for Static Configuration.

Static Typing.

Static Binding.



Parameterized Inheritance.


Member Types.

Nested Classes.

Prohibiting Certain Template Instantiations.

Static versus Dynamic Parameterization.

Wrappers Based on Parameterized Inheritance.

Template Method Based on Parameterized Inheritance.

Parameterizing Binding Mode.

Consistent Parameterization of Multiple Components.

Static Interactions between Components.

Components with Influence.

Components under Influence.

Structured Configurations.

Recursive Components.

Intelligent Configuration.

8. Aspect-Oriented Decomposition and Composition.

Why Is This Chapter Worth Reading?

What Is Aspect-Oriented Programming?

Aspect-Oriented Decomposition Approaches.

Subject-Oriented Programming.

Composition Filters.

Demeter / Adaptive Programming.

Aspect-Oriented Decomposition and Domain Engineering.

How Aspects Arise.

Composition Mechanisms.

Requirements on Composition Mechanisms.

Example: Synchronizing a Bounded Buffer.

“Tangled” Synchronized Stack.

Separating Synchronization Using Design Patterns.

Separating Synchronization Using SOP.

Some Problems with Design Patterns and Some Solutions.

Implementing Noninvasive, Dynamic Composition in Smalltalk.

Kinds of Crosscutting.

How to Express Aspects in Programming Languages.

Separating Synchronization Using AspectJ Cool.

Implementing Dynamic Cool in Smalltalk.

Implementation Technologies for Aspect-Oriented Programming.

Technologies for Implementing Aspect-Specific Abstractions.

Technologies for Implementing Weaving.

AOP and Specialized Language Extensions.

AOP and Active Libraries.

Final Remarks.

9. Generators.

Why Is This Chapter Worth Reading?

What Are Generators?

Transformational Model of Software Development.

Technologies for Building Generators.

Compositional versus Transformational Generators.

Kinds of Transformations.

Compiler Transformations.

Source-to-Source Transformations.

Transformation Systems.

Scheduling Transformations.

Existing Transformation Systems and Their Applications.

Selected Approaches to Generation.



Approaches Based on Algebraic Specifications.

10. Static Metaprogramming in C++.

Why Is This Chapter Worth Reading?

What Is Metaprogramming?

A Quick Tour of Metaprogramming.

Static Metaprogramming.

C++ as a Two-Level Language.

Functional Flavor of the Static Level.

Class Templates as Functions.

Integers and Types as Data.

Symbolic Names Instead of Variables.

Constant Initialization and typedef-Statements Instead of Assignment.

Template Recursion Instead of Loops.

Conditional Operator and Template Specialization as Conditional Constructs.

Template Metaprogramming.

Template Metafunctions.

Metafinctions as Arguments and Return Values of Other Metafinctions.

Representing Metainformation.

Member Traits.

Traits Classes.

Traits Templates.

Example: Using Template Metafunctions and Traits Templates to Implement Type Promotions.

Compile-Time Lists and Trees as Nested Templates.

Compile-Time Control Structures.

Explicit Selection Constructs.

Template Recursion as a Looping Construct.

Explicit Looping Constructs.

Code Generation.

Simple Code Selection.

Composing Templates.

Generators Based on Expression Templates.

Recursive Code Expansion.

Explicit Loops for Generating Code.

Example: Using Static Execute Loops to Test Metafunctions.

Partial Evaluation in C++.

Workarounds for Partial Template Specialization.

Problems of Template Metaprogramming.

Historical Notes.

11. Intentional Programming.

Why Is This Chapter Worth Reading?

What Is Intentional Programming?

Technology behind IP.

System Architecture.

Representing Programs in IP: The Source Graph.

Source Graph + Methods = Active Source.

Working with the IP Programming Environment.


Further Capabilities of the IP Editor.

Extending the IP System with New Intentions.

Advanced Topics.

Questions, Methods, and a Frameworklike Organization.

Source-Pattem-Based Polymorphism.

Methods as Visitors.

Asking Questions Synchronously and Asynchronously.


The Philosophy behind IP.

Why Do We Need Extendible Programming Environments? or What Is the Problem with Fixed Programming Languages?

Moving Focus from Fixed Languages to Language Features and the Emergence of an Intention Market.

Intentional Programming and Component-Based Development.

Frequently Asked Questions.



12. List Container.

Why Is This Chapter Worth Reading?


Domain Analysis.

Domain Design.

Implementation Components.

Manual Assembly.

Specifying Lists.

The Generator.


13. Bank Account.

Why Is This Chapter Worth Reading?

The Successful Programming Shop.

Design Pattems, Frameworks, and Components.

Domain Engineering and Generative Programming.

Feature Modeling.

Architecture Design.

Implementation Components.

Configurable Class Hierarchies.

Designing a Domain-Specific Language.

Bank Account Generator.

Testing Generators and Their Products.

14. Generative Matrix Computation Library (GMCL).

Why Is This Chapter Worth Reading?

Why Matrix Computations?

Domain Analysis.

Domain Definition.

Domain Modeling.

Domain Design and Implementation.

Matrix Type Generation.

Generating Code for Matrix Expressions.

Implementing the Matrix Component in IP.


Appendix A: Conceptual Modeling.

What Are Concepts?

Theories of Concepts.

Basic Terminology.

The Classical View.

The Probabilistic View.

The Exemplar View.

Summary of the Three Views.

Important Issues Concerning Concepts.

Stability of Concepts.

Concept Core.

Informational Contents of Features.

Feature Composition and Relationships between Features.

Quality of Features.

Abstraction and Generalization.

Conceptual Modeling, Object-Orientation, and Software Reuse.

Appendix B: Instance-Specific Extension Protocol for Smalltalk.
Appendix C: Protocol for Attaching Listener Objects in Smalltalk.
Appendix D: Glossary of Matrix Computation Terms.
Appendix E: Metafunction for Evaluating Dependency Tables.
Glossary of Generative Programming Terms.
Index. 020130977T04062001

Back Cover

Praise for Generative Programming

“The book develops strong themes around unifying principles that tie the pieces together, most notably domain engineering and metaprogramming. It's crucial to understand that this book is not just some refreshing diversionn or just an exposition of some noteworthy niche techniques. It is a harbinger of a broader enlightenment that opens the door to a new age.”

-from the foreword by JAMES COPLIEN, a Distinguished Member of Technical Staff at Lucent Technologies' Bell Laboratories, Naperville, IL

“Generative Programming offers a well-written and comprehensive discussion that integrates object technology and domain engineering. The authors' approach to software systems generation provides very clear insights into practices essential for systematic reuse and software product lines.”

-SHOLOM COHEN, a Senior Member of the Technical Staff of the Software Engineering Institute (SEI), Pittsburgh, PA, and a co-developer of the Feature Oriented Domain Analysis (FODA) method

“If you believe that the systems you develop today will share concepts with the systems you will develop tomorrow, then the practical techniques presented in this book will reduce your time to market, decrease your engineering costs, and improve your software quality. These techniques are essential for both practitioners and researchers concerned with modern system development.”

-JAMES NEIGHBORS, President of Bayfront Technologies, Inc., Newport Beach, CA, and the author of the Draco approach

“The authors present a grand tour of Generative Programming which is bound to become a classic. They properly focus on the generally unappreciated connection between Domain Specific Languages and Generative Programming as a motivation for future development. The wide-ranging and practical methods for Domain Analysis and Domain Engineering describe the first steps that developers can take right now. They are valuable both when existing systems are used or in preparation for emerging new generative technologies.”

-CHARLES SIMONYI, Chief Architect at Microsoft Research, Redmond, WA, and the inventor of Intentional Programming

Generative Programming (GP) offers great promise to application developers. It makes the idea of moving from Ione of a kindO software systems to the semi-automated manufacture of wide varieties of software quite real. In short, GP is about recognizing the benefits of automation in software development. Generative Programming covers methods and tools that will help you design and implement the IrightO components for a system family and automate component assembly. The methods presented here are applicable for all commercial development--from "programming in the small," at the level of classes and procedures--to "programming in the large," or developing families of large systems.

Generative Programming is your complete guide and reference to this emerging discipline. It provides in-depth treatment of critical technologies and topics including:

  • Domain Engineering
  • Feature Modeling
  • Generic Programming
  • Aspect-Oriented Programming
  • Template Metaprogramming in C++
  • Generators
  • Microsoft's Intentional Programming

Using this book you will learn how these techniques fit together and, more importantly, how to apply them in practice. The text contains three comprehensive case studies in three different domains: programming domain (container data structures), business domain (banking), and scientific computing (matrix computations).


Krzysztof Czarnecki is a researcher and consultant with the Software Engineering Lab at DaimlerChrysler Research and Technology in Ulm, Germany. He gained firsthand experience with Aspect-Oriented Programming and Intentional Programming during research visits at the Xerox Palo Alto Research Center and the Microsoft Research in Redmond, Washington. He received an M.S. degree in computer science from California State University at Sacramento, and M.S. and Ph.D. degrees in computer science from the University of Ilmenau in Germany.

Ulrich W. Eisenecker is a professor of computer science at the University of Applied Sciences Kaiserslautern at Zweibrocken, where he chairs the department for componentware and windows interfaces. Prior to his university career he spent nearly a decade in industry. He is an editor of a special supplement on component software of the German IT magazine OBJEKTspektrum, for which he also writes a C++ column. He has published more than a hundred articles, and frequently speaks at national and international IT conferences.