Do not Repeat Yourself

  • Observe that in the model on the previous page, three clafers (main_tracks, tracks_in, tracks_out) have identical properties (children) and identical constraints. This redundancy is irritating. Real variability models need reuse mechanisms as any other large models.

  • In Clafer, we use inheritance to reuse similar units of variability. Inheritance was not present in the original FODA feature models.

  • In the example, we extract an abstraction trackLine, which has to be configured to be either single or dual. The main_tracks, tracks_in and tracks_out are extended to inherit from it, instead of repeating the same configuration tree.

  • (not shown here) Clafers which specialize other clafers via inheritance, can be further extended, by adding more nested clafers.

abstract xor trackLine
single
dual
abstract RegionalStationConf
main_tracks : trackLine
tracks_in : trackLine
tracks_out : trackLine
parking_track ?
MyConfiguration : RegionalStationConf

This also illustrates why it might be useful to mix class modeling constructs with feature modeling. Feature modeling benefits from the reuse methods of OO-modeling, while class modeling benefits from very concise notation of feature models.

Task 3:

  • Use ClaferConfigurator again to quickly check whether we get the same instances (to properly check this, using this tool, you need to investigate all 16 instances).

  • As previously remember to switch to the Alloy instance generation, then press ‘Run’ and only then ‘Get instances’ (we are working on a new release of tools, but in the release used in this wiki the choco installation has some problems).



Previous
  1. Commonality
  2. Variability