Using FOP as an extension of OOP, composition of features can be reduced to composition of classes and class refinements. There are different possibilities to implement static composition of classes that are decomposed in feature-oriented approaches, using code generation. In the following, we introduce the code transformations performed by the FeatureC++ compiler that allow for static as well as dynamic binding of features.
Static composition of features means to combine the code of multiple features into one executable program. We refer to static binding if a feature is bound in an application before load time, e.g., in a preprocessing step or at compile time. FeatureC++ is based on a source-to-source code transformation from FeatureC++ code to plain C++ code. For static composition, the FeatureC++ compiler generates a statically composed C++ class from all selected FeatureC++ refinements of that class (i.e., refinements of the class that are extended by a feature selected for composition). FeatureC++ generates for each class with all of its refinements a compound class that consists of:
Using this kind of transformation, the C++ compiler can easily inline method refinements since they are early bound and composed into the same file. Based on such optimizations FeatureC++ provides the same performance as C++ code that does not support customization.