Configurable Systems

A configurable system is a system which behavior depends on configuration variables, also known as feature variables. These ones define distinct functionalties in an specific domain. A configurable system may be constructed using these feature variables, which are boolean variables that guard the inclusion of the functionality of the corresponding feature. They are annotated in the code in a way that one can access any of them from any part of the code, e.g., GPL is a configurable system with 13 feature variables.

GPL [1, 2] is a library of graph algorithms, which provides different options for modeling graphs and different operations on them. For example, it provides different choices of search algorithms and operations to compute the connected components of a graph. Here are the GPL’s feature variables:

  1. BASE: represents the common code for all the products;
  2. DIRECTED: represents a directed graph;
  3. UNDIRECTED: represents an undirected graph;
  4. WEIGHTED: represents a weighted graph;
  5. SEARCH: represents the kinds of search;
  6. BFS: represents breadth first search if enabled, depth first search otherwise;
  7. NUMBER: represents the vertex numbering;
  8. CONNECTED: represents connected components, with undirected graphs;
  9. STRONGLYCONNECTED: represents strongly connected components, with directed graphs;
  10. CYCLE: represents a circle graph; 
  11. MSTPRIM: represents a Prim algorithm;
  12. MSTKRUSKAL: represents a Kruskal algorithm;
  13. SHORTEST: represents a single source shortest path, using Dijkstra’s  Algorithm.

 

All these features are defined and annotated in the code, for instance, the class GPLVariables (see below) defines the feature variables used by GPL as well as the default values of each one. By default, all feature variables are setted to "0" (means false), except by BASE that is setted to "1" (means true), because BASE represents a common feature in GPL and it always should be enabled.

 

From the features definitions above, we can access any feature at any part of the GPL’s code, following are some examples:

 

 

A Test for a Configurable System

This kind of test is aware of the features, so it may set feature values in the test code, if necessary. Following there is a simple example of a test which needs setting the features SEARCH and WEIGHTED to true, because it is required by the methods VertexConstructor() and adjustAdorns(...).

This test and the GPL source code are available at: GPL.zip

 

References
[1] http://www.cs.utexas.edu/users/dsb/GPL/graph.htm
[2] ftp://ftp.cs.utexas.edu/pub/predator/GPL.pdf