105
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software
106
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software
107
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software
architectural design purposes. But a determine how they relate to each other
DSLs underlying structure - its abstract and if additional concepts are needed.
syntax, or metamodel [17] - can be For example, the metamodel shown in
used to formalize the variation space in Figure 3 includes, in addition to
particular areas of the domain Authoring, DocumentType and
(subdomains). It can introduce Relationship, obtained directly from the
constraints and rules that go beyond feature model, the relationships
the information contained in the feature between them, and new concepts, such
model, defining more precisely how the as a Author, Field and FieldType. This
applications vary in these areas, up to a metamodel describes the essence of the
point where design can start. Differently DSL and the variability in that particular
from feature-based variability, scenarios subdomain.
are not useful here, because there are
infinite variation possibilities. C. Identification of subdomain
Thus, we propose the identification integration drivers
and development of DSL metamodels to Having identified those drivers that
be used as architectural drivers. The describe feature-based and DSL-based
identification of a DSLs metamodel is variability, each one normally contained
based primarily on the feature model in a well-defined subdomain, the
[6], but the domain experts knowledge domain architect must deal with the
[3] is also important. It also depends on integration between them. For example,
the identification of the subdomains, by in the web domain (Figure 1A) the
analyzing for example the feature navigation subdomain may contain
dependencies [7] or their potential for references to the authoring subdomain
model-driven automation1. Each (e.g. a page that points to a specific
subdomain corresponds to a subset of document type). These subdomain
the domain, and has its own set of interdependencies must be made
features. explicit, so that the architecture can be
First, it is necessary to identify the prepared for the existence of multiple
features that will compose the DSLs subdomains and possibly multiple DSLs
metamodel. We propose that this task [10], [11]. It might be necessary, for
should begin by analyzing the domain example, to define a single metamodel
technology features [7]. These are the for multiple subdomains, and then
features that represent domain-specific develop different concrete
ways to implement services or
operations in a domain. In other words,
they are the domains building blocks
upon which the domain functions and
services (capability features) are
normally built. These domain
technology features are good
candidates to be part of a DSL.
Consider for example the web domain
shown in Figure 1A. In this domain, the
authoring subdomain can be identified.
The features representing this Figure 3. Definition of the authoring subdomain
subdomain (Authoring, DocumentType metamodel.
and Relationship) will be the starting syntaxes for each one of them, so that
point of the DSLs metamodel. These they can integrate well but still have
features are then further analyzed to different views.
1 Subdomains identification is out of To accomplish this task, every
the scope of this paper. Further reading subdomain (feature models and DSL
in [9] models) is inspected, looking for
108
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software
109
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software
present. The Decorator and Chain of The following listing shows a piece of
Responsibility patterns may be used JET3 code that generates class
when different features have DAOAbstractFactory. This code uses JET
functionalities that are complementary tags <c:iterate> and <c:get>, together
to each other. The Decorator is a with XPATH [22] queries, to iterate
structural pattern, more indicated for through all document types and
the cases where the interaction generate one creator method for each
between several features is complex, document type.
but well defined. The Chain of public abstract class DAOAbstractFactory
Responsibility is a behavioral pattern, { <c:iterate select="/documentTypes"
i.e., the structure of the interaction is var="d"> public abstract <c:get
select="$d/@name" /> create<c:get
not well defined, and thus it is more
select="$d/@name" />Instance();
indicated for simpler feature </c:iterate>
interactions. In both cases, the behavior }
is encapsulated in specific methods,
classes, or the Command pattern, and For document types News, Project
the generator is responsible for and Reference, the class on the upper
producing the method calls that left corner of Figure 4 is generated.
correspond to the selected features. To illustrate how this pattern
Optional features. For optional facilitates the task of the code
features, the same set of patterns used generator, consider the following piece
for the Or features can be used, with of JET code:
the difference that in this case it is not <c:iterate select="/documentTypes"
necessary to guarantee that at least var="d">
<c:choose>
one feature is present in the application. <c:when
Figure 4 shows an example of test="$featuresModel/@derby=true">
application of the abstract factory <java:class name="{$d/@name}"
design pattern being used for template="DerbyDAOClass.java.jet" />
alternative features. </c:when>
<c:when
test="$featuresModel/@mysql=true">
<java:class name="{$d/@name}"
template="MySQLDAOClass.java
.jet" />
</c:when>
</c:choose>
</c:iterate>
110
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software
4
B. DSL-based variability patterns www.isis.vanderbilt.edu/projects/gme/
The patterns in this category are and www.eclipse.org/modeling/
focused on how the DSL-based tools and
code generators can be integrated with
the other domain artifacts. One
111
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software
to one team only. The team working are divided in four categories, according
with code generation may focus on its to the dependency between generated
own tasks. and non-generated code:
A second pattern is the features data Generated code depends on non-
layer. Normally, the feature model is a generated code. This is the simpler type
central point of information for of interaction, and consists of making
generators, even those that are the generator produce code that uses
exclusively dedicated to DSL-based existing, non-generated code, such as a
variability. This pattern proposes that a framework or API.
common data layer holds all the The Facade [21] pattern can be used
information related to the features. This to simplify the interaction between
data layer must be designed to be generated and non-generated code.
accessed by any generator, allowing it Instead of generating code that uses
to query feature information while multiple classes and methods, a single
generating code. If there is a tool for Facade class can group all necessary
feature modeling, a separate thin data classes and methods. This not only
layer can be used to hold feature data makes the dependencies more explicit,
without depending on that particular but can also provide some protection
tool. against changes in the non-generated
The second code sample in Section IV- code. Depending on how deep the
A illustrates the features data layer change is, it might not be necessary to
pattern. Instead of directly reading from change the generator, which is a more
the feature model, the XPATH queries complex, error-prone task.
$featuresModel/@derby=true and To shield the generator from
$featuresModel/@mysql=true access a modifications in the nongenerated code,
separate data layer, stored in a the adapter [21] pattern may be used,
temporary slot represented by to collect, filter and/or prepare the
$featuresModel. This temporary slot information needed by the generated
contains only the necessary information code. The bridge [21] pattern may be
from the features model that is actually used with the same purpose, creating
used by the code generators. The an abstract representation of the
following code shows the general idea referenced code, that is free to be
of how this layer can be populated using modified to introduce simpler
JET jags <c:load> and <c:set>. In this modifications. Partial classes are
example, the derby feature is another way to accomplish this, as
selected: shows the following code:
<%-- load from product configurator tool -- // This file is generated public
%> partial class ClientNodeObject
<c:load url="features.xmi" var="conf"/> { public ClientNodeObject(int
<%-- inspect conf to see which features port) {
are selected. and set necessary // generated init code
variables --%> _initData();
<c:set select="$featuresModel" }
name="derby">true< }
/c:set>
<c:set select="$featuresModel" // This file is handwritten public
name="mysql">false partial class ClientNodeObject
</c:set> { void
_initData()
{
C. Subdomain integration patterns
// handwritten code
These patterns aim to provide a good }
integration between generated and non- }
generated software, particularly in those
areas involving a subdomains In this example, written in C#, the
boundaries. The patterns in this section compiler is responsible for integrating
the two files in a single class.
112
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software
113
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software
114
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software
directly caused by the approach and the the use of a higher level architectural
produced architecture or by other design approach, the reusable code can
factors remains a threat to the study. To remain generic, while the final code is
soften this uncertainty, an interview was made specific through code generation.
also conducted with the participants of The automation also helped to reduce
the third case study. The interview errors in customization.
consisted of open questions about the Another aspect raised by the
participants impressions on the participants was the fact that reuse was
benefits and difficulties of using the high without the approach, but at the
approach. cost of having large pieces of unused
code copied into the product. This was
A. Results and analysis Table II shows
causing some confusion, specially in
the results of the evaluation. Metrics M4,
maintenance. The approach helped to
M5 and M6 could not be extracted for
reduce that.
Study 3 because we could not find an
The participants also reported that the
automated tool to extract them from
modeling and code generation
non-OO PHP code, which was used in
technologies are difficult to learn,
this domain.
requiring a shift of thought to correctly
In the first two studies, we observed
use them. The participants had basic
an increase in the reuse level, in terms
modeling skills and worked as
of LOC, either considering reuse without
programmers for two years, never
modification (M1) and with minor
having worked with MDE before.
modifications (M2). The degree of
However, they managed to implement
undesired reuse (M3) was also slightly
the required functionality after a
reduced in this first two studies. For the
16hours training about MDE.
third study, however, the reuse level in
Table III summarizes our observations,
terms of LOC was reduced when the
which indicate that the proposed drivers
approach was used. In fact, the reuse
and patterns may bring benefits in
level was already high without the
many situations, but a trade-off analysis
approach. On the other hand, the
must be carried out to evaluate its
undesired reuse is considerably smaller
drawbacks of increased complexity,
when the approach was used.
decreased maintainability and a high
For study 1, which is a relatively
learning curve. Projects similar to study
simple technical domain, we observed
2, i.e. involving more complex technical
that the resulting architecture had an
domains, seem to be the best
improved overall stability of the
candidates for using our approach.
modules. However, they were, in
St Main observations
average, more complex and more
d
difficult to maintain. For study 2, which 1 Architecture resulted in increased reuse,
involved a more complex technical but at the cost of more complex and less
domain, the complexity of the maintainable modules
architecture was reduced, without 2 Architecture resulted in increased reuse,
affecting too much the maintainability. less complex and more maintainable
For study 3, an interview was modules
conducted. During this interview, the 3 MDE-based approach is difficult to learn but
participants reported that the approach facilitates product customization and
helped to solve some problems that makes reuse more focused
could not be solved by hand, in Table III
MAIN OBSERVATIONS IN THE CASE STUDIES
particular the many customizations that
must be made every time a product is
sold. They tried to parameterize some
of these in the code, but this often
B. Threats to validity
caused loss of generality, and so this
solution was abandoned. With MDE and There are some threats to the validity
of this study. The participation of one of
115
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software
116
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software
the issues we discussed in this paper [2] L. Bass, P. Clements, and R. Kazman,
are important. Software Architecture in Practice, 2nd
Edition. Addison-Wesley, 2003.
Our research aims at providing a more
systematic way to perform domain [3] J.-P. Tolvanen and S. Kelly, Defining
domain-specific modeling languages to
design considering the requirements of automate product derivation: Collected
a domain engineering effort that will experiences, in 9th SPLC-Europe, ser.
benefit from MDE techniques. The main LNCS, vol. 3714. Springer, 2005, pp.
198209.
contributions of this research are the
identification of specific architectural [4] K. Czarnecki, S. Helsen, and U.
drivers and patterns that can be used to Eisenecker, Staged configuration using
feature models, in 3rd SPLC, ser. LNCS
produce a domain-specific software 3154. Springer, 2004, pp. 266283.
architecture, and the description of how
to deal with them using existing and [5] L. B. Lisboa, ToolDAy - A Tool for
Domain Analysis, Masters thesis,
new patterns. Federal University of Pernambuco,
We also provided the results of an Recife, Pernambuco, Brazil, 2007.
evaluation. Despite the threats to its
[6] K. Czarnecki, Overview of generative
validity, we consider that valuable software development, in Int. Work. on
observations could be made. The Unconventional Programming
qualitative and quantitative data Paradigms, France, Sept, 2004, ser.
LNCS, vol. 3566. Springer, 2005, pp.
pointed out that the approach is 326341.
feasible, and may lead to benefits in
terms of software development. The [7] K. Lee and K. C. Kang, Feature
dependency analysis for product line
resulting architecture helped to increase component design, in 8th ICSR, Madrid,
the reuse level, as observed in two of Spain, 2004, pp. 6985.
the three case studies, and also make it [8] J. Bartholdt, R. Oberhauser, and A.
more focused, as observed in one of the Rytina, An approach to addressing
studies. The proposed patterns also entity model variability within software
product lines, in ICSEA. IEEE, 2008, pp.
seems to help dealing with the design of 465471.
architectures for more complex
domains, like the one involving [9] D. Lucredio, R. P. d. M. Fortes, E. S. d.
Almeida, and S. R. d. L. Meira,
distributed cloud-based applications. Performing domain analysis for
But we observed some drawbacks that modeldriven software reuse, in 10th
need to be considered in a trade-off ICSR, ser. LNCS, vol. 5030. Springer,
2008, pp. 200211.
analysis prior to using our approach.
As future work, we are planning [10] J. Warmer and A. Kleppe, Building a
further experiments with these drivers flexible software factory using partial
domain specific models, in 6th OOPSLA
and patterns, to refine and extend Workshop on Domain-Specific Modeling,
them. The results from the first case 2006, pp. 1522.
studies are promising, and we expect
[11] A. Hessellund, K. Czarnecki, and A.
that the completion of more Wasowski, Guided development with
experiments can deliver more solid multiple domain-specific languages, in
results to the interested community. MODELS, ser. LNCS, vol. 4735. Springer,
2007, pp. 4660.
ACKNOWLEDGEMENTS
[12] K. Kang, S. Cohen, J. Hess, W. Novak,
This work was partially supported by and A. Peterson, Feature-oriented
the National Institute of Science and domain analysis (FODA) feasibility
study, SEI/CMU, Tech. Rep. CMU/SEI-90-
Technology for Software Engineering TR-21, 1990.
(INES - www.ines.org.br), funded by
CNPq and FACEPE, grants 573964/2008- [13] K. Kang, J. Lee, and P. Donohoe,
Feature-oriented product line
4 and APQ-1037-1.03/08. engineering, IEEE Soft., vol. 19, no. 04,
pp. 5865, 2002.
REFERENCES
[14] A. Fantechi, S. Gnesi, G. Lami, and E.
[1] P. Clements and L. Northrop, Software Nesti, A methodology for the derivation
Product Lines: Practices and and verification of use cases for product
Patterns.Addison-Wesley, 2002.
117
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software
lines, in 3rd SPLC, ser. LNCS, vol. 3154. EUROMICRO Conference. IEEE/CS Press,
Springer, 2004, pp. 255265. 2004, pp. 372
379.
[15] E. F. Ecklund, Jr, L. M. L. Delcambre, and
M. J. Freiling, Change cases: Use cases [26] S. R. Chidamber and C. F. Kemerer, A
that identify future requirements, in metrics suite for object oriented
Conference Proceedings of the OOPSLA design, IEEE Trans. Softw. Eng., vol. 20,
96, San Jose, CA, USA. ACM Press, 1996, no. 6, pp. 476493, 1994.
pp. 342358.
[27] J. S. Poulin and J. M. Caruso, A reuse
[16] E. Visser, WebDSL: A case study in metrics and return on investment
domain-specific language engineering, model, in 2nd ACM/IEEE Int. Workshop
in GTTSE 2007, ser. LNCS, vol. 5235. on Soft. Reusability. IEEE/ACM, 1993,
Springer, 2007, pp. 291373. pp. 152167.
[17] G. Guizzardi, L. F. Pires, and M. J. V. [28] P. Devanbu, S. Karstu, W. Melo, and W.
Sinderen, On the role of domain Thomas, Analytical and empirical
ontologies in the design of domain- evaluation of software reuse metrics, in
specific visual modeling languages, in 18th ICSE. IEEE, 1996, pp. 189199.
2nd Workshop on Domain-Specific
Visual Languages, OOPSLA, 2002. [29] R. Martin, OO design quality metrics:
An analysis of dependencies, 1994,
[18] F. Buschmann, R. Meunier, H. Rohnert, P. available at:
Sommerlad, M. Stal, P. Sommerlad, and http://www.objectmentor.com/resources/
M. Stal, Pattern-Oriented Software articles/oodmetrc.pdf. Access in
Architecture, Volume 1: A System of mar/2010.
Patterns. John Wiley & Sons, 1996.
[30] T. J. McCabe, A complexity measure,
[19] M. Volter and J. Bettin, Patterns for IEEE Transactions on Software
model-driven software development, Engineering, vol. 2, no. 4, pp. 308320,
in EuroPLoP 2004, Irsee, Germany, 1976.
2004, pp. D31D354.
[31] K. D. Welker and P. W. Oman, Software
[20] E. S. Almeida, A. Alvaro, V. C. Garcia, L. maintainability metrics models in
M. Nascimento, D. Lucredio, and S. R. d. practice, Crosstalk, Journal of Defense
L. Meira, A systematic approach to Software Engineering, vol. 8, no. 11, pp.
design domain-specific software 1923, 1995.
architectures, Jour. of Soft.
- Academy Publisher, vol. 02, no. 2, pp. 38 [32] K. Czarnecki and M. Antkiewicz,
51, 2007. Mapping features to models: A
template approach based on
[21] E. Gamma, R. Helm, R. Johnson, and J. superimposed variants, in 4th GPCE,
Vlissides, Design Patterns: Elements of ser. LNCS, vol. 3676. Springer, 2005, pp.
Reusable Object-Oriented Software. 422437.
Add.-Wesley, 1995.
[33] D. Perovich, P. O. Rossel, and M. C.
[22] W3C, XML path language (XPath) Bastarrica, Feature model to product
version 1.0 - W3C recommendation 16 architectures: Applying MDE to software
november 1999, World Wide Web product lines, in WICSA/ECSA 2009.
Consortium, Tech. Rep., 1999. IEEE, 2009, pp. 201 210.
[23] K. Czarnecki and S. Helsen, Feature- [34] M. Alferez, U. Kulesza, A. Sousa, J.
based survey of model transformation Santos, A. Moreira, J. Araujo, and V.
approaches, IBM Syst. Jour., vol. 45, no. Amaral, A model-driven approach for
3, pp. 621645, 2006. software product lines requirements
engineering, in SEKE. Knowledge
[24] M. Genero, G. Poels, and M. Piattini, Systems Institute Graduate School,
Defining and validating metrics for 2008, pp. 779784.
assessing the understandability of
entityrelationship diagrams, Data [35] J. E. Perez-Mart nez and A. Sierra-
Knowl. Eng., vol. 64, no. 3, pp. 534557, Alonso, From analysis model to
2008. software architecture: A PIM2PIM
mapping, in ECMDA-FA, ser. LNCS, vol.
[25] J. Muskens, M. Chaudron, and C. Lange, 4066. Springer, 2006, pp. 25
Investigations in applying metrics to 39.
multi-view architecture models, in 30th
118