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 eithersingle
ordual
. Themain_tracks
,tracks_in
andtracks_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.
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).
- Close the configurator and move to the page Domain Constraints.
Previous