Specification of Products and Product Lines: Ariel Gonzalez Carlos Luna
Specification of Products and Product Lines: Ariel Gonzalez Carlos Luna
The study of variability in software development has become increasingly important in recent years.
A common mechanism to represent the variability in a product line is by means of feature models.
However, the relationship between these models and UML design models is not straightforward.
UML statecharts are extended introducing variability in their main components, so that the behavior
of product lines can be specified. The contribution of this work is the proposal of a rule-based ap-
proach that defines a transformation strategy from extended statecharts to concrete UML statecharts.
This is accomplished via the use of feature models, in order to describe the common and variant com-
ponents, in such a way that, starting from different feature configurations and applying the rule-based
method, concrete state machines corresponding to different products of a line can be obtained.
1 Introduction
A product line (PL), also called system family, is a set of software systems sharing a common, managed
set of features that satisfy the specific needs of a particular market segment or mission and that are
developed from a common set of core assets in a prescribed way [1, 2, 3].
To develop a system family as opposed to developing a set of isolated systems has important advan-
tages. One of these is the possibility of building a kernel that includes common features, from which
desired products can be easily built as extensions. By adding distinguishing characteristics (variability)
to such a kernel, different products can be obtained [3, 4, 5, 6, 7, 8]. For example, today we observe
in the market a significant number of different types of mobile phones (MPs) that share a core of basic
features and differ in other more specific characteristics: availability of a digital camera, internet access,
mp3 player, among others.
The UML language [9] provides a graphical notation and has become the standard for modeling
different aspects of software systems. Statecharts and interaction diagrams are part of the set of tools
that UML provide so that the system behavior can be specified, which are specially suitable for the
software design phase. Statecharts are used to specify the behavior of the instances of a class (intra-
component behaviour), and therefore constitute an appropriate mechanism for describing the behavior of
certain problems by means of a graphical representation. In the latest version of UML 2.0, the statecharts
do not offer operators and/or sublanguages for specifying system families.
In this paper we propose an extension of UML statecharts for modeling PLs. We used feature models
so that both common and variant functionality of a system family can be described [10, 8], and we
incorporate variability in the essential components of the statecharts, in such a way that, starting from
different configurations of a feature model, concrete statecharts corresponding to different products of
a PL can be generated applying a rule-based method. The approach defines the transformation strategy
from extended statecharts to concrete UML statecharts.
The rest of the work is organized as follows. In section 2 and 3 we briefly introduce statecharts and
feature models, respectively. Section 4 presents an extension of statecharts with variant elements, which
together with the use of feature models allow specifying PLs. In section 5 we detail the mechanisms
for obtaining products of a PL from distinct configurations of a feature model, via the use of rules and
a transformation strategy. Related work is discussed in section 6 and finally, we conclude and discuss
possible further work in section 7. We exemplify the proposed work by developing part of a case study
based on mobile phone technology. A preliminary version of this work is [11]. As opposed to [11], this
paper presents a rule-based approach. We define an application strategy for the rules in a proper manner,
in such a way that inconsistencies are avoided in the statechart obtained. The rules are organized in a
sequence of rule sets, in which each rule set can be considered as a layer. Within a rule set, the rules may
be applied in a non-deterministic order [12]. We also formalized and added rules that in [11] are omitted
or only described informally.
2 Statecharts
UML StateCharts (SCs) constitute a well-known specification language for modeling the dynamic system
behavior. SCs were introduced by D. Harel [13] and later incorporated in different versions of the UML
with some variations. In this section, we present definitions of SCs based on [14]. For additional details,
the reader is referred to [11, 14].
SCs consist essentially of states and transitions between states. The main feature of SCs is that states
can be refined, defining in this way a state hierarchy. A state decomposition can be sequential or parallel.
In the first case, a state is decomposed into an automata (Or-state). The second case is supported by a
complex statechart composed of several active sub-statecharts (And-state), running simultaneously.
Let S, T R, Π and A(Π ⊆ A) be countable sets of state names, transition names, events and actions of a
SC, respectively. Also, let us define s ∈ S as either a basic term of the form s = [n] (Simple-state), as a term
Or of the form s = [n, (s1 , ..., sk ), l, T ] (Or-state), or as a term And of the form s = [n, (s1 , ..., sk )] (And-
state), where name(s) =de f n is the name of the state s. Here (s1 , ..., sk ) are the subterms (substates) of s,
also denoted by sub est(s) =de f (s1 , ..., sk ). Likewise, inicial(s) =de f s1 is the initial state of s, T ⊆ T R is
the set of internal transitions of s, and l the active state index of s. A transition is represented as a tuple t =
(t 0 , so , e, c, α, sd , ht), where name(t) =de f t 0 is the transition name, source(t) =de f so and target(t) =de f sd
are called source and target of t, respectively, ev(t) =de f e the trigger event, cond(t) =de f c the trigger
condition, and acc(t) =de f α is the sequence of actions that are carried out when a transition is triggered.
In addition, hist(t) =de f ht is the history type of the target state of t [14]. The graphical notation used in
the transitions is t : e, c/α.
3 Feature Models
Feature Models (FMs) are used to describe properties or functionalities of a domain. A functionality
is a distinctive characteristic of a product or object, and depending of the context it may refer to, it is
a requirement or component inside an architecture, and even code pieces, among others. FMs allow
us to describe both commonalities and differences of all products of a PL and to establish relationships
between common and variant features of the line. There are multiple notations for describing FMs. In
this work we will use the proposal of Czarnecki [10].
A tree structure instance is a FM configuration (FMConf) that describes the model and that respects
the semantics of their relations. That is, a FM allows one to identify common and variant features
between products of a PL, while a FM configuration characterizes the functionalities of a specific product.
Formally, the concepts of FMs are defined as follows:
46 Specification of Products and Product Lines
Definition 1. A FM is defined as a tree structure represented by a tuple (Funcs, f0 , Mand, Opt, Alt,
Or-rel), where Funcs is a set of functionalities of a domain (nodes of the tree), f0 ∈ Funcs is the root
functionality of the tree and, Mand, Opt, Alt, Or-rel ⊆ Funcs × (γ(Funcs) − {0}) / the mandatory, op-
tional, alternative and disjunct relations of the model, respectively. If (f,sf)∈ Mand ∪ Opt, #sf = 1.
Definition 2. A FM configuration corresponding to a FM (Funcs, f0 , Mand, Opt, Alt, Or-rel) is a
tree (F, R) where F is the set of nodes and R the set of edges; F ⊆ Funcs and R ⊆ {(f,sf)∈ F×(γ(F)−{0}) /
| ∃ sf’ ∈ γ(Funcs): sf ⊆ sf’ ∧ (f,sf’) ∈ Mand ∪ Opt ∪ Alt ∪ Or-rel}. Moreover, the following conditions
must be fulfilled by (F, R): (1) f0 ∈ F; (2) for every (f,sf) ∈ Mand: if f ∈ F then (f,sf) ∈ R; (3) if (f,sf)
∈ Alt ∧ f ∈ F then ∃! sf’∈ γ(F): sf’⊆sf ∧ (f,sf’) ∈ R ∧ #sf’=1; (4) if (f, sf) ∈ Or-rel ∧ f ∈ F then ∃!
sf’∈ γ(F): sf’⊆sf ∧ (f,sf’) ∈ R ∧ #sf’≥1.
Definition 3. The kernel N of a FM (Funcs, f0 , Mand, Opt, Alt, Or-rel) is the set of functionalities,
which are present in all configurations, inductively characterized by the following rules: (1) f0 ∈ N; (2)
if f1 ∈ N ∧ ( f 1, { f 2}) ∈ Mand then f2 ∈ N.
functionalities the capacity to make calls by means of quick-marked, to write text messages, to adminis-
ter multimedia contents, and combinations of these, such as messages with multimedia content (images,
polyphonic sounds and videos). In order to exhibit an example in the development of this article, we
formulate in figure 3 a FM, using the notation proposed by Czarnecki, that relates the involved function-
alities in the partially described MP of figure 2.
The composition of two transitions t1 = (t1 , so1 , e1 , c1 , α1 , sd1 , ht1 , no optional) and t2 = (t2 , so2 ,
e2 , c2 , α2 , sd2 , ht2 , no optional) define a new transition as follows: comp(t1, t2) = (t12 , so1 , e1 :: e2 ,
c1 ∧ c2 , α1 :: a2 , sd2 , ht2 , no optional), where :: is the sequential composition of events and actions, and
∧ the conjunction of conditions. Both operations must be associative in order to make the instantiation
method deterministic.
Let sc = (S∗ , T R∗ , Π∗ , A∗ ) be SC∗ (in future, we will omit the components Π∗ y A∗ ), we define the
set of entry and exit non-optional transitions pairs of a state E of sc as follows:
Te s (E) = {(te ,ts ) ∈ T R∗ ×T R∗ | target(te ) = E ∧ source(ts ) = E ∧ TransType(te ) = TransType(ts ) =
no optional}.
The result of eliminating an optional Simple-state E of sc corresponds to the following SC∗ :
Delete simple state(E, (S∗ , T R∗ )) = (S∗ − {E}, T R∗ ∪ {comp(te , ts )| (te ,ts ) ∈ Te s (E)} − {t ∈ T R∗ |t ∈
Domain(Te s (E)) ∨ t ∈ Range(T e s(E))} − {t ∈ T R∗ | TransType(t) = optional ∧ (source(t) = E ∨
target(t) = E)}) We call this rule Delete simple state(E, (S∗ , T R∗ )). Figure 4 shows the result of their
application.
Case 1.2. When a Or-state is deleted
If an Or-state s = [E, (s1 , ..., sk ), l, T ] is deleted, then their entry and exit optional transitions are
deleted, while the mandatory transitions are composed using the following rebuilding method.
The proposal consists of applying the previous transition composition method of case 1.1 on E,
considering certain conditions and affectations to SC∗ . Let sc = (S∗ , T R∗ ) be a SC∗ , we previously
define the set of all the entry and exit non-optional transition pairs of an Or-state E of sc∗ as follows:
Te s (E) = {(te ,ts ) ∈ T R∗ ×T R∗ |target(te ) ∈ sub states(E)∧ source(ts ) ∈ sub states(E)∧ TransType(te )
= TransType(ts ) = no optional}
We establish that each entry transition to E is composed with one exit transition if the source state of
the exit transition is reached from the target state of the entry transition. We define Reachable(E, A) as
50 Specification of Products and Product Lines
the set of reachable substates of E from the substate A. Formally, we define TCompe s (E) = {(te ,ts ) ∈
T e s(E)| source(ts ) ∈ Reachable(E,target(te ))} as the set of transition pairs that must be composed by
means of case 1.1, previous modification of these transitions as is indicated as follows. For each entry
transition te ∈ Domain(TCompe s (E)) its target state is now E, i.e., target(te ) = E. Also, for each exit
transition ts ∈ Range(TCompe s (E)), source(ts ) = E. The result of eliminating the optional Or-state E
of sc∗ corresponds to the SC∗ following:
Delete Or state(E, (S∗ , T R∗ )) = (S∗ − ({E} ∪ sub states(E)), T R∗ ∪ {comp(change target(te , E),
change source(ts , E))| (te ,ts ) ∈ TCompe s (E)} − {t ∈ T R∗ |source(t) ∈ ({E} ∪ sub states(E)) ∨target(t)
∈ ({E} ∪ sub states(E))})
change target(t,E) change the target of transition t, such that target(t)=E. Likewise, change source(t,
E) change the source of transition t, such that source(t)=E. We call this rule Delete Or state(E, (S∗ ,
TR∗ )).
Case 1.3. When an And-state is deleted
If an optional And-state E is deleted, then their entry and exit optional transitions are deleted, while
the mandatory transitions are composed using a similar rebuilding method to case 1.2.
Two possible relations of dependency or synchronization between parallel states exist. One of them
refers to the occurrence of an event that produces the trigger of two or more transitions belonging to each
one of the parallel substates. The second relation corresponds to using conditions of type ‘in E’ (see case
2.2). The latter forces to redefine the concept of reachability, since it is not valid to apply the previous
definition of reachability in a way independent in each one of the orthogonal states.
Let E be an And-state with n orthogonal states. We define now Reachable(E, (E1 , E2 , ..., En )) as
the set of n-tuples of reachable states from (E1 , E2 , ..., En ). In this way, maintaining the definition of
Te s (E) of the previous case and redefining TCompe s (E), it is possible to solve the method of transition
elimination and composition (Delete And state) in an analogous form to case 1.2.
TCompe s (E) = {(te ,ts ) ∈ Te s (E)|(∃ n-tupla init, n-tuple end ∈ (S∗ ×S∗ ×...×S∗ )n | n-tupla end ∈
Reachable(E, n-tupla init)∧(∃i, j1 ≤ i, j ≤ n|n-tupla end[i] = source(ts )∧n-tupla init[ j] = target(te )∧
cond(ts )))}, being n the amount of orthogonal states. We call to this rule Delete And state (E, (S∗ , TR∗ )).
strategy is terminating because the rules decrease components of the statecharts (either states or transi-
tions).
In general, confluence means that, when there is a choice of applying different rules, the choice does
not affect the result. The role of the first two rules is to avoid ill-formed statecharts. The main rule is
Delete simple state(E, sc), since Delete Or state(E, sc) and Delete And state(E, sc) are based on this.
Note that Delete simple state(E, sc) does not produce ill-formed statecharts (see case 1.1).
r (r1 , r2 )
The application of a rule r on a SC∗ is denoted by sc∗i → sc∗i+1 , and sc∗i → sc∗i+2 denotes the
application of r1 y r2 in that order.
Lemma 1. (Applying two rules.) Let r1 , r2 ∈ {Delete simple state(E, sc), Delete Or state(E, sc), Delete
And state(E, sc)} be two rules to be applied to states E1 and E2 ∈ NSC( f mc, sc), respectively.
(r1 , r2 ) (r2 , r1 )
sc∗i → sc∗j ∧ sc∗i → sct∗ ⇒ sc∗j = sct∗ .
Proof. Let E1 and E2 ∈ NSC( f mc, sc) be the states to eliminate. We consider both independent if there
is no transition which connects, in this case it is clear that the elimination in any order produces the
same SC. The opposite case is discussed. Let tE1 = (tE1 , so1 , a1 , c1 , α1 , E1 , ht1 , non optional), tE1 E2 =
(tE1 E2 , E1 , a12 , c12 , α12 , E12 , ht12 , non optional) and tE2 = (tE2 , E2 , a2 , c2 , α2 , sd2 , ht2 , non optional) be
entry and exit transitions of E1 and E2 . On the one hand, we assume that the rule Delete simple state(E1 ,
sc) is applied before rule Delete simple state(E2 , sc), i.e. tE1 is composed with tE1 E2 and after compose
with tE2 .
comp(comp(tE1 , tE1 E2 ),tE2 ) = tE1 (E1 E2 ) E2 = (tE1 (E1 E2 ) E2 , so1 , (a1 :: a12 ) :: a2 , (c1 ∧c12 )∧c2 , (α1 ::
α12 ) :: α2 , sd2 , ht2 , non optional).
On the other hand, if we assume now the inverse application of both rules, we can see that the
resulting composition has the same result as the previous case. Given that the operators ∧ and :: are
associative: comp(comp(tE1 , tE1 E2 ), tE2 ) = comp(tE1 , comp(tE1 E2 , tE2 )).
The rules Delete Or state and Delete And state are based on the rule Delete simple state, therefore
we may consider E1 and E2 (see above) as compound states.
Let SC∗ , R y SR be a rule-based rewriting system on Statecharts (RS-SC), where R is the set of rules
defined in section 5.1 and SR the implementation strategy on the rules of R. Let ValSeq SR be the set of
all valid sequences of applications.
An RS-SC execution starting from a SC∗ (sc∗ ) is a sequence s of rule applications of R such that
s
s ∈ ValSeq SR . We denote it by sc∗ → sc, where sc ∈ SC is a concrete statechart.
Theorem 1. (Confluence.) Two distinct executions of RS-SC generate the same statechart.
s s
sc∗ →
1
sc ∧ sc∗ →
2
sc0 ⇒ sc = sc0 .
6 Related Works
A variety of existing approaches propose the incorporation of variability in software systems and in par-
ticular on PLs. One of these is the one designed by Jacobson [15], whose weaknesses have been analyzed
by several authors. Von der Maen [4] proposes the use of a graphical notation with new relations. John
and Muthig [16] suggest the application of use case templates, although they do not distinguish between
optional, alternative or obligatory variants. However, Halman and Pohl propose in [17] to make use of
UML 2 package merge, based on [6], as a tool for the variability representation and configuration in PLs.
As opposed to the mentioned proposals, our solution is centered in one behavior specification model of
a PL, as are the SCs, introducing a clearly defined formal sustenance.
Also, to define PLs and to characterize their different products we use FMs, which admit a formal
definition and allow us to configure the functional characteristics of a line. An alternative approach to this
paper is developed in parallel by other members of the research project in which this work is subsumed.
In [18] the authors, in a formal framework, define functions that associate SCs (not components of SCs,
as in our case) to functionalities of a FM, and analyze forms of combination between different SCs
which specify possible variants of a PL. Whereas under our method the behavior of a product into a
PL is obtained basically by a selection process, in [18] the focus is oriented towards a process of SC
combinations.
54 Specification of Products and Product Lines
Figure 5: SC for a MP without polyphonic sounds and without alert of new messages.
Most of the techniques of Model Driven Development make use of UML. In particular, the SCs of UML
constitute a mechanism for specifying systems behavior by means of a graphical representation. In this
work, we presented an extension of UML SCs by incorporating variability in their essential components
to specify PLs. The variability is introduced in the SCs distinguishing optional and non-optional states as
well as optional and non-optional transitions. A PL is specified with a SC∗ , a FM, and a formal relation
(an implementation function) that binds both models. Using FMs to describe the common and variant
functionalities and applying a rule-based instantiation method, concrete SCs corresponding to different
PLs can be obtained. The approach defines the transformation strategy from extended SCs to standard
UML SCs. We develop partial examples of a case study based on mobile phone technology, whose full
version is not included in this article due to space restrictions.
Given the fact that UML and SCs have become very successful languages for analysis and design in
A. Gonzalez & C. Luna 55
the very short run, we are confident that the results of this work can be successfully applied to the real
problems of the software industry. It is a timely contribution to an authentic and actual problem.
As part of our plans for future work, we are interested in an extension of SCs which allows us to
completely cover the UML 2.0 SCs and analyze variabilities, not only the ones considered in this paper,
but in all of their components. Also, we will make an attempt to provide a formal semantics for the
extension. This semantics is an essential preliminary step towards both the automatic code generation
and the validation of complex software systems.
References
[1] P. Clements, L. Northrop. Software Product Lines: Practices and Patterns. SEI Series in Software Engineer-
ing, Addison-Wesley. 2002.
[2] H. Gomaa: Designing Software Product Lines with UML: From Use Cases to Pattern-based Software Archi-
tectures. The Addison-Wesley Object Technology Series, 2004.
[3] K. Kang, J. Lee, and P. Donohoe. Feature-Oriented Product Line Engineering. IEEE Soft., 19(4):58-65, 2002.
[4] T. von der Maßen, H. Lichter. Modeling Variability by UML Use Case Diagrams. In Proc. of the International
Workshop on Requirements Engineering for Product Lines (REPL’02), 2002.
[5] G. Halmans, K. Pohl. Communicating the Variability of a Software-Product Family to Customers. Journal of
Software and Systems Modeling 2, 1 2003, 15–36.
[6] A. Zito, Z. Diskin, and J. Dingel. Package merge in UML 2: Practice vs. theory? In O. Nierstrasz, J. Whittle,
D. Harel, and G. Reggio, editors, MoDELS/UML 2006, October 2006.
[7] M. Clauß. Generic modeling using Uml extensions for variability. In Workshop on Domain Specific Visual
Languages at OOPSLA 2001, 2001.
[8] K Czarnecki, M. Antkiewicz. Mapping Features to models: a template approach based on superimposed
variants. In Proc. GPCE’05, LNCS 3676, Springer, pp. 422-437.
[9] Object Management Group: OMG Unified Modeling Language Specification Version 2.0, 2004. Available at
http://www.uml.org.
[10] K. Czarnecki and U.W. Eisenecker. Generative Programming: Methods, Techniques, and Applications.
Addison-Wesley, 2000.
[11] C. Luna, A. González. Behavior Specification of Product Lines via Feature Models and UML Statecharts
with Variabilities. In Proc. of SCCC’08, Chile, IEEE CS Press. pp. 32-41, 2008.
[12] Jochen M. Küster. Definition and validation of model transformations. Journal of Software and Systems
Modeling, 5(3) 233-259, 2006.
[13] D. Harel: Statecharts: A visual formalism for complex systems. Science of Computer Programming, 8: 231-
274,1987.
[14] M. von der Beeck. A structured operational semantics for UML-statecharts. Software and System Modeling,
1(2):130-141, 2002.
[15] I. Jacobson, M. Griss and P. Jonsson . Software Reuse. Architecture, Process and Organization for Business
Success. ACM Press. Addison Wesley Longman. 1997.
[16] John, I., Muthig, D.: Tailoring Use Cases for Product Line Modeling. In Proc. of the International Workshop
on Requirements Engineering for Product Lines (REPL’02), 2002.
[17] M. Laguna, B. González-Baixauli, O. López. Gestión de la Variabilidad en Lı́neas de Productos. In Proc. of
CLEI07, Costa Rica, Octubre de 2007.
[18] N. Szasz and P. Vilanova. Statecharts and Variabilities. In proc. of the Second International Workshop on
Variability Modelling of Software-intensive Systems, Essen, Germany, 2008.