Anda di halaman 1dari 14

IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software

Diseo de arquitecturas de dominios para la ingeniera


impulsada por modelos

Daniel Lucredio, Renata P. M. Fortes, Eduardo S. Almeida and Silvio L.


Meira
Computing Department - Federal University of Sao Carlos, Sao Carlos - SP -
Brazil
Institute of Mathematical and Computing Sciences - University of Sao Paulo, S ao
Carlos - SP - Brazil
Computing Science Department - Federal University of Bahia, Salvador - BA - Brazil
Recife Center for Advanced Studies and Systems - Recife, PE, Brasil
Corresponding author: daniel@dc.ufscar.br
Resumen ModeloDriven Ingeniera (MDE) puede Escenario posible, debe construirse la arquitectura
aprovechar del software
Ingeniera de dominio, ofreciendo soporte a la En torno al concepto de MDE, siendo consciente y
variabilidad compleja y la implementacin dando apoyo
automtica. Sin embargo, poca atencin es el A sus tecnologas, para que el desarrollo de
proceso de diseo de una arquitectura de dominio aplicaciones
que se adapta bien a las tcnicas del MDE, como Proceso puede aprovechar al mximo sus
las Idiomas y transformaciones de software. Un beneficios.
dominio especfico la arquitectura del software se Sin embargo, la mayora de los enfoques
desarrolla normalmente sobre la base de orientados a modelos para
Y los requisitos importantes, llamados Gineering y la ingeniera de lnea de productos se
conductores de la arquitectura. centran en el producto
Este documento presenta tres tipos de Derivacin, despus de que la arquitectura ya
conductores de arquitectura que Puede utilizarse est definida (dos
para construir una arquitectura de software que Ejemplos son [3], [4]). En general, no se presta
Ventaja de los beneficios de MDE. Tambin suficiente atencin
presenta algunos El proceso de diseo de una arquitectura que sea
Patrones que se pueden utilizar para ayudar en el Bien adaptado para MDE. Tratamos de abordar
diseo arquitectnico. Un Tambin se presenta esta cuestin en
una evaluacin, que muestra que, cuando se En De dos maneras: (i) identificando tres tipos de
un proyecto de ingeniera de dominio impulsado Conductores de arquitectura [2] Y (ii)
por modelos, estos controladores Y los patrones presentando algunos patrones
pueden conducir a algunos beneficios en trminos Para tratar con ellos. Cuando se usan juntos,
de reutilizacin Y complejidad, pero que en facilitan
algunos casos hay inconvenientes La tarea de disear arquitecturas para MDE. Los
Que deben ser considerados en un anlisis de conductores
tradeoff. Guiar al arquitecto del dominio a travs de la
Palabras clave de ingeniera- model impulsada identificacin del
Ingeniera de dominios Conductores de Diferentes posibilidades de variabilidad del
arquitectura patrones Lenguajes especficos del dominio, mientras que los patrones
dominio cdigo Generacion Ayuda aportando soluciones a algunos de los
problemas
En el diseo de dominio impulsado por modelos.
I. INTRODUCTION
Tambin presentamos los resultados de una
Una de las tareas principales de la ingeniera de Demostrar la viabilidad, los beneficios y los
Definir una arquitectura de software especfica del inconvenientes de
dominio que Utilizando estos controladores y patrones.
Comunidad y variabilidad [1]. La arquitectura no
debe II. DOMAIN VARIABILITY AND MODEL-DRIVEN
Slo predicen los puntos de variacin, sino que
ENGINEERING
tambin
El soporte necesario, normalmente en forma de Variability is the key concept behind a
comPonentes successful domain architecture [1].
[2]. La ingeniera impulsada por el modelo (MDE)
Este proceso con lenguajes especficos de dominio There are two kinds of domain
y transformaQue variability [6]: routine configuration - a
Proporcionan apoyo para una variabilidad y una subset of features is selected to
Implementacin automatizada.
configure a product, using tree-like
Para que esta ingeniera de dominio impulsada
por modelos (MDDE) structures; and creative construction -

105
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software

models describe the variation through


graph-like structures.
Most domain design approaches rely
on the identification of variability as
described in terms of features [7]
externally observable characteristics of
a product. Feature modeling is located
somewhere between routine
configuration and creative construction
[6], and has already been used in many
successful cases. However, there are
other kinds of variation, such as in
entity models [8], which are more
complex than it is possible to capture in
feature models, because they are too
generic [3]. These require a richer Figure 1. Web authoring domain features and different produc
mechanism, with more expressive with ToolDAy [5].
power to capture detailed relationships deselected. Instead, they need to be
and constraints between entities. The combined in a creative way to configure
technology of choice for this is normally a product (Figure 1C).
a Domain-Specific Language (DSL) [3], This is where a DSL comes in hand. It
[6]. Together with model is a language that describes the domain
transformations and code generators, concepts and how they can relate to
DSLs form the basis of Model-Driven each other. Using a DSL, one can create
Engineering (MDE). models that capture more detailed
For example, consider a web variability. In the previous example, a
authoring domain involving publish- domain designer could use a web
navigate applications. An administrator authoring DSL to specify which
publishes information, such as news, document types will be present in an
posts, messages, etc. that can be application, and how they relate to each
accessed by users. News websites, other, or which pages will be available,
forums and blogs are some example and how navigation between them
applications of this domain. Figure 1A occurs.
shows a feature model for this domain. Since a domain usually comprises
Using this model, it is possible, for both types of variability, it can be
example, to configure a product by divided into subdomains [9], each one
selecting optional features like simple described in terms of feature-based
search and user content submission variability (routine configuration) or
(Figure 1B). But the four domain DSL-based variability (creative
technology features in the bottom of construction). Also, these different
Figure 1A cannot be merely selected or subdomains must effectively cooperate
in order to support the variability, i.e.
the individual feature models and DSLs
must be integrated [10], [11].

III. DESIGNING A DOMAIN-SPECIFIC


SOFTWARE ARCHITECTURE FOR MDE
The process of designing a domain-
specific software architecture is usually
carried out by an architect, together
with the stakeholders, who can identify
the main quality attributes that are
important for a particular domain [2].

106
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software

These are called architectural drivers - a A change case is a scenario that


combination of functional and quality describes a variation point considering
requirements that shape the the presence of one or more variants.
architecture. To identify them, the most For example, consider a domain
important business objectives must be featuring simple and advanced search
analyzed, and those that have most options. Figure 2A describes the use
impact in the architecture must be case for simple search, and Figure 2B
chosen as drivers [2]. describes advanced search. Note that,
For Model-Driven Domain Engineering, in Figure 2B, steps 2, 3 and 4 substitute
we defined three types of architectural the normal behavior when the
drivers that must be identified: (i) advanced search variant is present. The
Feature-based variability, (ii) DSL-based related features and the affected
variability and (iii) Subdomain scenarios are also registered, to indicate
integration. In the following sections we where the changes occur.
discuss some techniques to help to Change cases have the advantage of
identify them. In the following representing complete scenarios. This
discussions, we assume that domain facilitates architectural evaluation,
analysis has already been conducted, so because the stakeholders can fully
a feature model is available at this understand how a scenario works
point. without having to interpret specific tags
or analyze combinations between
A. Identification of feature-based alternatives. However, they result in
variability drivers longer descriptions and some
Domain features identification and duplication.
variability analysis is normally
performed during domain analysis [12],
[13]. So, at this point the domain
architect already has a good idea about
the similarities between domain
applications and how they may differ
from each other.
But for the architectural design to
begin, more concrete information is
needed. The architect needs to know
details about what happens when a
particular feature is present or absent,
Figure 2.Example of a change case introduci
when two related features are
combined, etc. A common technique for
B. Identification of DSL-based
this particular task is to use scenarios. A
variability drivers
scenario is a brief description of
behavior that illustrates certain Some authors have proposed
conditions - like the presence of a extensions to the basic feature
particular feature - and serves to test an modeling technique for this purpose [4].
architectures capacity in satisfying one However, even the extended feature
or more quality attributes [2]. model has a fixed, generic notation.
There are different ways to map the This may not be a problem in the
variability at the features level into beginning, during variability analysis,
scenarios that describe the variability. but later in the MDE process this generic
For example, use cases with inclusion notation is unable to represent all the
and exclusion relationships or special complexities and details required for
tags that define variation points can be code generation [3].
used [14]. Here we propose the use of DSL development is a complex, time-
another concept to derive these consuming task [16], and thus it is not
scenarios, called change cases [15]. viable to build a complete DSL just for

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

elements (features or DSL A. Feature-based variability patterns


metaelements) that depend on an In a previous work [20], we presented
element in a different subdomain. how some of the GoF patterns [21] can
Multiple uses of the same name, help making the architecture ready for
synonyms and homonyms can point the different types of feature-based
these out. Next, the dependencies must variability. Here, we extend that work by
be documented in a clear way, highlighting how MDE integrates with
annotating the feature models and the each pattern and specifying which parts
DSL models, or using a separate can be automatically generated. The
document that lists these dependencies. scenario is the following: a feature
model describes the common and
IV. ARCHITECTURAL PATTERNS FOR MODEL- variable parts. A code generator takes
DRIVEN ENGINEERING as input a selection of features/sub-
The architectural drivers described in features that will be part of the
Section III provide detailed information generated application, and produces the
about how variation occurs in the corresponding code. Depending on the
different subdomains. With this type of feature, a different pattern can
information in hand, the architect can be applied.
devise a domain-specific software Alternative features. These are
architecture that gives the necessary features where only one alternative
support for MDE. from a group can be present in an
The architectural design is a creative application. When a feature can be
process, requiring experience and directly mapped into a single class, we
knowledge about the domain. This task suggest the use of the Prototype
is normally carried out with the help of pattern. Each alternative is
patterns to facilitate the design [2]. It is implemented as a different subclass of a
up to the architect to decide how to common prototype. The code generator
combine the available patterns is responsible for generating code that
according to the identified drivers, or instantiates only the selected
even propose new patterns to design alternative.
the architecture. If a feature must be implemented by
A list of well-known patterns is available different classes, we suggest the use of
in the literature the Abstract Factory or Factory Method
[2], [18], but they normally do not deal patterns. These allow, through
with variability and MDE-related issues. inheritance of the factory, to build more
Thus, we present some architectural than one class (ConcreteProduct) for the
patterns for dealing with the identified same feature. To automate this pattern,
drivers, highlighting how they can be the alternative features are
integrated with MDE artifacts, implemented as concrete products, and
particularly the code generators. Some the generator is responsible for
of the patterns are based on [19], which producing the concrete factory or
are useful to MDE projects. But since factory method that corresponds to the
these are not specific for architectural selected alternative.
design or domain engineering, we When the alternatives are different
provide further discussions on these behaviors that can be mapped to a
aspects. Those patterns that do not single method, the Strategy or Template
appear elsewhere (thin layer and Method patterns may be used. These
features data layer - Section IV-B) were are similar to prototype, but only a
observed at least in our case studies, method is overridden. In this case, the
but we are aware that more experience generator must produce the method
is needed to increase their generality. calls for the selected alternative.
Or features. These are alternative
features where more than one
alternative from a group may be

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>

Here, JET tags <c:choose> and


<c:when> are used to select among
mutually exclusive alternatives, in this
case, alternative features derby and
mysql, which are obtained from the
features model through XPATH queries.
Figure 4. Depending on the choice, JET tag
Example of abstract factory being used
for alternative features. <java:class> calls the appropriate
template. For document types News,
In this example, there are two Project and Reference, three from
alternative features, each one for a the six concrete classes on the lower
different database management right side of Figure 4 are generated. A
system: Apache Derby and MySQL2. similar construction produces the
Depending on which feature is selected, concrete factory (DerbyDAOFactory or
a different set of classes is generated.
2 http://db.apache.org/derby/ and 3 Java Emitter Templates
http://www.mysql.com (http://www.eclipse.org/modeling/m2t)

110
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software

MySQLDAOFactory) for the selected particularity about these patterns is


feature. that, after the MDE process is finalized
There are also two patterns that can and the code generation takes place,
be used for featurebased variability, the patterns disappear from the
based on well-known good practices architecture of the final product. This
[23] for writing code generators: happens because they belong to a
different meta-level. However, they do
have impact on domain success, helping
to shape an architecture that is better
prepared for tasks like domainspecific
modeling and code generation.
A first pattern we propose is called
thin data layer, which facilitates the
Figure 5. Visitor pattern applied to feature-based
integration between the generator and
code generation. the DSL tool/modeler. Normally, code
generators read information directly
The first pattern (Figure 5) is known as from a DSL tool, which can be created
the visitor approach [23]. In this manually or with a language workbench
pattern, the input model is traversed such as GME or the Eclipse modeling
and every element is visited. For each project4.
element, a corresponding template is
called, according to the model
elements type. In the domain
engineering scenario, it can be
particularly useful for different types
of mandatory and optional features
[7]. A visitor traverses the features
model and, for each selected feature, Figure 6.Thin data layer pattern.
calls the corresponding template.
Normally, each template produces a This pattern, shown in Figure 6,
single class fitting into the
advocates the use of a separate data
architecture through design patterns
layer, built in a technology that is
such as the above.
The visitor approach is a good choice independent from the DSL tool, and that
when it is possible to encapsulate a contains the information that is
features functionality in a single class. essential to the generator, and nothing
If not, a second pattern can be used, else. In this way, the information
known as the template approach [23]. It needed by the generator is made
consists of a single entry point, explicit, which facilitates the evolution
responsible for querying the models and of both the generator and the DSL tool.
calling other templates. This approach It also allows the development of both
may be used in different types of sides in parallel (one team developing
variability, because it is more flexible, the generator and another team
being particularly useful to implement developing the tools/metamodels).
or features [7]: a main template Finally, it frees the generator from a
analyzes the feature models and particular modeling technology, and
decides which templates to call based restricts the need for learning the
on the selected features. particularities of a specific modeling tool

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

Non-generated code depends on Environment

generated code. This happens when Table I


some non-generated code expects that SUMMARY OF THE CASE STUDIE
some behavior or structure is model. Although not ideal, this
generated. In most cases, patterns such simplifies the process of implementing
as abstract factory, template method or cross-model references [11].
factory [21] can be used, so that the Another option are model bridges,
non-generated code does not need to which consist in creating duplicates of
know details about how the classes or elements from the referenced
methods it uses are actually metamodel into the referencing
implemented. metamodel. In the web authoring
The following non-generated Java example, this corresponds to the
code illustrates how the dependency is creation, in the navigation metamodel,
reduced through the abstract factory of an element called
pattern. In this example, this non- ReferenceToDocumentType, or
generated Java code depends on the something similar, that can be used to
derby feature being selected, but establish references between
there is no need for much detail, as the metamodels. A separate checker can
abstract factory pattern hides most of it: make sure that these references are
public class DefaultDAOFactoryProvider valid [10].
{ private static DAOAbstractFactory
theInstance = null; V. EVALUATION
public static DAOAbstractFactory
To evaluate our approach, we
getDefaultDAOFactoryInstance() {
if(theInstance == null) theInstance conducted three case studies, described
= new DerbyDAOFactory(); in Table I. The first study involved the
return theInstance; web content authoring domain, which is
} a technical domain that includes
}
applications for publishing and viewing
Generated code depends on information, such as news websites,
generated code. This usually happens forums and blogs. It was performed in a
when there are two subdomains that purely academic scenario. The second
depend on each other. One issue that and third studies were performed in
arises when multiple subdomains are conjunction with the industry. The
related is how to ensure this second study involved the domain of
relationship between them. One distributed cloud-based applications,
possibility is to use the names of the which is also a technical domain,
elements as references, i.e. the name of dealing mainly with peer-to-peer
a reference in one model must match communication and discovery
the name of the referenced element in functionalities. The third case study
another involved the domain of scientific events,
Study number 1 which is a business domain. All three
Domain Web Authoring case studies took a similar amount of
Location ICMC/USP - Sao Carlos/SP -
Brazil
time, although the third study had
Participants 1 (author) smaller duration and only parttime
Duration 3 months (full-time) availability of the participants. The third
Num. DSLs 4
Num. generation artifacts 38 case study was the largest in terms of
Size (LOC) generation 1610 lines of code of the reference
artifacts
Size (LOC) ref. 5941
implementation, but smaller in terms of
implementation the generation artifacts, which reflects
Num. of domain features 15 the fact that the participants had less
Implementation Apache Tomcat, MySQL, Java,
technologies time to implement MDE automation.
JSP, JSTL, Servlets, XML, SQL,
Eclipse The objective of these studies was to
MDE technologies Eclipse Modeling, JET (Java evaluate if the proposed drivers and
Emitter Templates)

113
IV Simpsio Brasileiro de Componentes, Arquiteturas e Reutilizao de Software

patterns can help to produce an M4: Module instability. This metric


architecture that is better suited for aims at evaluating how difficult it is to
MDE, so the idea was to make a modify a piece of software [29]. The
comparison between existing metric ranges from zero to one, where
implementations, developed without zero means a stable (easy to modify)
them, and the resulting MDE-based module, and one means an instable
implementation, developed with them. (difficult to modify) module.
For all studies, the same participants M5: Cyclomatic complexity. This is a
were responsible for developing the two classic complexity metric [30], based on
versions (with and without our the number of paths inside a program.
approach). Values between 1 and 10 indicate
There are few model-oriented metrics simplicity, and values above 50
available, and experience have shown represent complex modules. In the
that these are often not reliable [24]. context of this research, complexity is
Some authors have used classic object- an important indicator of how the
oriented metrics to evaluate models architecture is facilitating tasks like
[25], [26], arguing that they are more implementation, maintenance and
stable and can detect the same software reuse.
problems that will appear in the code,
M6: Maintainability index. This metric
M1 M2 M3 M4 M5 M6
WO W WO W WO W WO W WO W WO W
Study 36.0 93.3 43.7 93.3 3.32 0 0.55 0.48 2.26 3.91 114.8 82.32
1 4 2 0 2 8 8 7 6 91 9
Study 64.4 82.6 65.6 82.6 16.6 10.0 0.49 0.47 3.25 2.05 120.3 118.0
2 7 6 6 6 8 1 6 9 2 4 33 63
Study 82.1 74.4 96.1 94.6 51.4 21.8 - - - - - -
3 5 5 1 9 3 8
Table II
EVALUATION RESULTS. WO = WITHOUT APPROACH, W = WITH APPROACH.
but earlier in the process. We decided to is an attempt to determine how easily a
follow this second line of thought and module can be maintained, by
use more reliable metrics: combining a series of empirical
M1: RP - Reuse Percent. Reused LOC / measurements, like the Halstead
Total LOC. This is a classic reuse metric volume and cyclomatic complexity [31].
[27], which counts as reused any line of Values below 65 indicate low
code that is reused without maintainability, while values above 85
modification. indicate good maintainability.
M2: RR - Reuse Ratio. The same as M1, These metrics were collected with the
but here artifacts that suffer only a help from tools
small modification (less than 25% of the Eclipse Metrics, JHawk and Net2Java 5.
code is modified) are considered reused Manual extraction was also necessary
as well [28]. for those artifacts, such as code
generation templates, not supported by
M3: Undesired Reuse Percent. The
the automatic tools.
reuse of large pieces of unused code
Using these indirect metrics, we tried
may distort the reuse percent metric.
to obtain a picture of how the approach
For this reason, we defined metric M3,
can influence different factors in
which consists of calculating the lines of
software development. Knowing
code that are reused (copied to the new
whether the observed results are
context) but are not being used. IDE
functions that find methods that are not
being called can be used to collect 5 metrics.sourceforge.net,
these data. www.virtualmachinery.com/jhawkprod.ht
m and net2java.dev.java.net

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

the authors of this paper in two of the on a different meta-level, including


studies may have influenced the results. transformations and code generators
Also, the fact that we were not able to that will disappear from the final
collect the metrics for the third study products architecture. The main
made our conclusions less generalized. difference from our work is that we
The use of indirect metrics is also a include an explicit concern about more
threat to this kind of experiment. detailed variability, applying DSLs in
We consider that the fact that the parts of the domain to achieve more
same participants developed the expressive power, while Perovich et al.
domain infrastructure with and without use only feature models as a starting
the approach did not influence the point for product configuration.
results, because the approach actually In [34], the authors present a model-
encourages the reuse of existing driven approach for requirements
software to develop the DSLs and code engineering in a product line context. As
generators. in our research, they defend the idea
Finally, the realization of experiments that features should be complemented
in an industrial scenario makes it with additional models to better
difficult to control all the influencing represent variability. Composition rules
factors and variables, and thus the between use cases are used similarly to
results can be strongly biased. This is the concept of change cases, but
also aggravated by the fact that the without the benefit of producing single
studies were realized in more than one scenarios that can be used in
country, in different environments and evaluation. Also, their work do not
with different cultures. However, this is present details about how the
also a good thing, because it increased architecture is obtained, with patterns,
the diversity and overall confidence in for example.
the results. The work described in [35] presents
an approach to derive the architecture
VI. RELATED WORK from analysis models using semi-
Czarnecki et al. [32] present a automatic transformations. However, it
template-based approach for generating is assumed that the analysis models are
models from feature models. Through rich enough to be automatically
mappings between features and general transformed into an architecture. Also,
models, such as data or behavioral only a single architectural style (C2
models, richer information can be [35]) is supported. And finally, the
associated with features. When applied approach is focused on single product
to architectural models, more detailed development, not covering reuse-
variability can be specified, which is related issues such as variability
similar to our approach. However, support and product derivation.
differently from Czarnecki et al.s work,
we also address the issues that result VII. CONCLUDING REMARKS AND FUTURE
WORK
from the inclusion of MDE-specific
artifacts, such as domain-specific MDE can leverage domain engineering
modelers and code generators. through techniques that support more
Perovich et al. [33] propose an complex variability and automatic
approach that uses features to implementation. In general, the
modularize architectural decisions. literature is more focused on the
These are made concrete through automatic product derivation process.
model transformations that There is no doubt that this is the final
automatically produce architectural goal to be achieved, and we agree with
fragments that correspond to the that. However, little attention is given to
selected features. As in our approach, the process of producing a domain
the architecture is an artifact that sits architecture that is prepared for this
kind of automation, and we believe that

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

Anda mungkin juga menyukai