In feature-oriented software development, feature-oriented software development program cubes are n-dimensional arrays of functions that represent n-dimensional product lines. A program is a composition of features: a base program is augmented with increments in program functionality, called features, to produce a complex program. A software product line is a family of related programs. A typical product line has F0 as a base program, and F1..Fn as features that could be added to F0. Different compositions of features yield different programs. Let + denote the feature composition operation. A program P in SPL might have the following expression: P = F8 + F4 + F2 + F1 + F0 That is, P extends program F0 with features F1, F2, F4, and F8 in this order. We can recast P in terms of a projection and contraction of a 1-dimensional array. Let Fi = denote the array of features used by a product line. A projection of Fi eliminates unneeded features, yielding a shorter array Gi. A contraction of Gi sums each Gi in a specific order, to yield a scalar expression. The expression for P becomes: P = Fi where the index values accomplish projection and summation is array contraction. This idea generalizes to n-dimensional arrays that model multi-dimensional product lines.
Multi-dimensional product lines
A multi-dimensional product line is described by multiple interacting sets of features. As an elementary 2D example, it is easy to create a product line of calculators, where variants offer different sets of operations. Another variation might offer different presentation front ends to calculators, one with no GUI, another with a Java GUI, a third with a web GUI. These variations interact: each GUI representation references a specific calculator operation, so each GUI feature cannot be designed independently of its calculator feature. Such a design leads to a matrix: columns represent increments in calculator functionality, and rows represent different presentation front-ends. Such a matrix M is shown to the right: columns allow one to pair basic calculator functionality with optional logarithmic/exponentiation and trigonometric features. Rows allow one to pair core functionality with no front-end, with optional GUI and web-based front-ends. An element Mij implements the interaction of column feature i and row feature j. For example, the element labeled cb is a base program that implements the core functionality of a calculator. Element gb adds code that displays the core functionality as a GUI; element wb adds code that displays the core functionality via the web. Similarly, element ct adds trigonometric code to the core calculator functionality; elements gt and wt add code to display the trigonometric functionality as a GUI and web front-ends. A calculator is uniquely specified by two sequences of features: one sequence defines the calculator functionality, the other the front-end. For example, calculator C that offers both base and trig functionality in a web format is defined by the expression: C = Mcb + Mct + Mwb + Mwt = Mij
Cubes
In general, a cube is an n-dimensional array. The rank of a cube is its dimensionality. A scalar is a cube of rank 0, a vector is a cube of rank 1, and a matrix is rank 2. Following tensor notation: the number of indices a cube has designates its rank. A scalar S is rank 0, Vk is a vector, Mij is a matrix, Cijk is a cube. Program Cubes are n-dimensional arrays of functions that represent n-dimensional product lines. The values along each axis of a cube denote either a base program or a feature that could elaborate a base program. The rank of a product line is the rank of its cube. A program in an n-dimensional SPL is uniquely specified by n sequences of features S1..Sn, one per dimension. The design of a program is a scalar that is formed by projecting the cube of its unneeded elements, and contracting the resultant kcube to a scalar: P = Ki1...in Program generation is evaluating the scalar expression to produce program P. An interesting property of cube design is that the order in which dimensions are contracted does not matter—any permutation of dimensions during contraction results in a different scalar expression, but all expressions produce the same value. For example, another expression to produce calculator C contracts dimensions in the opposite order from its original specification: C = Mcb + Mwb + Mct + Mwt Or more generally: P = Ki1...in The significance of program cubes is that it provides a structured way in which to express and build multi-dimensional models of SPLs. Further, it provides scalable specifications. If each dimension has k values, an n-cube specification of a program requires O terms, as opposed to O cube elements that would otherwise have to be identified and then composed. In general, cubes provide a compact way to specify complex programs.
Applications
The expression problem is a fundamental problem in programming languages aimed at type systems that can add new classes and methods to a program in a type-safe manner. It is also a fundamental problem in multi-dimensional SPL design. The expression problem is an example of an SPL of rank 2. The following applications either explain/illustrate the expression problem or show how it scales to product lines of large programs. EP is really a SPL of ~30 line programs; the applications below show how these ideas scale to programs of >30K lines.