Capturing variability with domain-specific modeling languages (Part 1)
One typical place to apply domain-specific languages is to express variability: When developing multiple similar products you have a language that describes what is different among family members. In this post, and in coming parts, I discuss how modeling languages can be defined for product lines. For the start I use Krzysztof Czarnecki's classification as he nicely illustrates the range of variation and different ways to handle them (see figure below).

Wizards recognize the dependencies that pure parameter list ignore. Wizards typically expect that all functionality is already available and the number of variation points is usually rather modest. Feature models, instead, are used to manage a larger number of variation points but are still limited - by nature variability is not only in static structures or come in a structure of a tree. You may see an illustrative example of this by looking the Feature Model example I implemented (source available in MetaCase Forum). The sample feature model illustrates the variation in a digital wrist watch product line. With Feature Models we can’t express variation that deals with behavior side, like for instance execution order. While several extensions are proposed for feature models their best use is at planning and analysis phases rather than in creating variants.
Richer and larger spectrum of variability, notably also dynamic behavior, can be covered with domain-specific languages. Krzysztof uses the wrist watch as an illustration of a DSL This example product line is supported by two languages, one targeting static variation and the other, as illustrated in the figure above (see a bigger picture here), targets more the dynamic parts. Since the language's concepts (metamodel) can be instantiated in many different ways, a domain-specific language can handle a greater range of variants. If the language is based on some more expressive model of computation, like state machine in the figure above, there are also capabilities to create functionality that is not yet available! This is most relevant in practice since we almost never have situation in which all variability is available and we can just pick among them.
Looking from the language design perspective this means that variation is not expressed purely as values to be selected (parameters in a table or features in a tree) but also with dedicated types: Variability is supported right in the language. In terms of metamodeling variation point is not just a property value of an object, but it can be a role that an object may have, a relationship that connects objects, submodels or diagrams an object or a relationship has to specify its details, links to other elements properties, ports and so on. If we step outside the basic language concepts that modeling languages have, such as Graphs, Objects, Roles, Relationships, Ports, Properties, further variation space can be set with rules related to languages, such as how many instances can be in a model or a single diagram, how many times a certain element may connect to another kind of element, etc.
I’ll discuss guidelines for creating domain-specific modeling languages to specify variability in coming posts.


