=Paper= {{Paper |id=Vol-1554/PD_MoDELS_2015_paper_5 |storemode=property |title=Reflecting on Model-based Code Generators Using Traceability Information |pdfUrl=https://ceur-ws.org/Vol-1554/PD_MoDELS_2015_paper_5.pdf |volume=Vol-1554 |authors=Victor Guana,Eleni Stroulia |dblpUrl=https://dblp.org/rec/conf/models/GuanaS15a }} ==Reflecting on Model-based Code Generators Using Traceability Information== https://ceur-ws.org/Vol-1554/PD_MoDELS_2015_paper_5.pdf
 Reflecting on Model-based Code Generators Using
              Traceability Information
                                                Victor Guana and Eleni Stroulia
                                                Department of Computing Science
                                                      University of Alberta
                                                     Edmonton, AB. Canada
                                                  {guana, stroulia}@ualberta.ca


   Abstract—Model-based code generators use model-to-model           system concerns [4]. Lastly, model-to-text transformations take
and model-to-text transformations to systematize the construction    this intermediate models, and produce code in a general-
of software systems. They integrate rule-based and template-         purpose language, such as Java or C++, that can be compiled
based transformation languages to translate high-level specifica-
tions into executable code and scripts. Given the complexity and     and executed [5].
heterogeneity of the underlying transformation languages, flexible      Numerous challenges remain open to make the construc-
traceability tools are needed to collect and visualize information   tion and maintenance of model-based code-generators less
about their architecture and operational mechanics. In this paper,   tedious and less brittle to evolution [6] [7]. Despite of the
we present ChainTracker, a traceability analysis environment         multiple research addressing the technical aspects of building
for model-based code generators. ChainTracker helps developers
to reflect on the composition of model transformations during        code-generators, relative few researchers investigate the core
the different stages of their construction and maintenance.          software-engineering problems behind their complex technol-
Furthermore, we describe a family of software-engineering tasks      ogy ecosystems.
that developers have to complete during the construction of             In this paper, we reflect on two challenges that affect devel-
model-based code generators, and how ChainTracker makes the          opers when building and maintaining code generators, namely,
execution of these tasks less error prone and less cognitively
challenging.                                                         (a) the platform evolution of code generators, and (b) the
                                                                     overwhelming complexity of code-generation architectures.
                       I. I NTRODUCTION                              The former refers to the difficulties that developers face when
   Model-based code generators use models as a vehicle to            the to-be-generated systems must fulfill new requirements and
capture a system’s specification. Domain-specific languages          the generation artifacts must also synchronously evolve to
with high-level semantics enable developers to create mod-           reflect those changes. The latter stems from the fact that non-
els using well-formed constructs [1]. In turn, these models          trivial model transformations are hard to understand, given that
are input into model-transformation compositions to derive           they heavily rely on textual scripts with cryptic operational
executable and/or deployment artifacts, such as source-code          semantics, and are composed in complex transformation chains
text and configuration scripts [2]. By raising the level of          that hard to mentally visualize and study.
abstraction for the software specification and making extensive         The contribution of this paper is twofold. We first present
reuse of executable assets, model-based code-generators make         ChainTracker, a visualization and trace-analysis environment
the construction of software systems less error prone, less          that uses traceability information about model-transformation
expensive, and, potentially, less challenging to non-computer        compositions, to support developers maintaining the complex
experts [3].                                                         operational mechanics behind model-based code generators.
   The role of model-based code generators is very similar to        Second, we discuss how ChainTracker supports a number
that of compilers, translating a general-purpose programming         of software-engineering tasks involved in the construction of
language to machine code. In this sense, a code generator            model-based code generators, ranging from tracing tangled
for a domain-specific language uses model transformations            code-generation artifacts, to summarizing information that
that inject execution semantics to the high-level models, and        assesses the quality of the generation process.
produces code based on templates that have been previously
engineered for reuse. Domain-specific languages are typically                             II. R ELATED W ORK
associated with graphical or textual notations; using these             During the life-cycle of a model-based code-generator, the
notations, developers can express system specifications in           generated code is often manually improved [7] [8]. The goals
terms with application-domain semantics. Such definitions are        of these code modifications are bug fixing, code-performance
ruled by metamodels that constrain how the concepts relate           optimization, and functionality extensions [9][10]. This pro-
to each other. In the transformation process, model-to-model         cess is known as platform evolution in model-driven en-
transformation languages are used to split, merge, or augment        gineering [8]. Due to the high complexity of the model-
the information provided in the initial specification, potentially   transformation compositions that live at the core of the code
producing multiple intermediate models that capture different        generators, and the complexity of the generated code itself,
Fig. 1. ChainTracker - Main Screen (1) Transformation-composition Branch View; (2) Transformation Script Viewers; (3) Transformation In/Out Bindings
Information Tables; (4.a) Filter and Transformation-script Visualization Options; (4.b) Context-aware menu to isolate artifacts related to metamodel elements
or generated textual artifacts.


backwardly propagating code refinements to the generation                       specification of model-to-model transformations (such as in
architecture is a challenging task [11]. Some of the questions                  ATL [20]), and template-based model-to-text transformation
that developers have to answer when facing platform evolution                   technologies (such as Acceleo [21]) that allow the derivation
include, what portions of code have been changed in the                         of source-code files [5].
generated codebases? and, assuming that a code change                              ChainTracker is an integrated analysis environment de-
should indeed be propagated, what elements of the underlying                    signed to support developers of model-based code genera-
models and transformations should be revised?.                                  tors by making model-driven engineering technologies more
   Most state-of-the-art tools that support platform evolution                  efficient, less error prone, and less cognitively challenging.
in model-based code-generators tackle the problem using                         ChainTracker provides an integrated analysis environment
traceability information. Van Amstel et al. [12][13] have used                  to visualize models and heterogeneous model-to-model and
traceability information of model-to-model transformations                      model-to-text transformation compositions, through interac-
to visualize their operational mechanics. Other researchers                     tive canvases and source-code viewers. Furthermore, Chain-
[14] [15] [16] have used traceability information to assess                     Tracker collects and summarizes traceability information
the quality of model-transformation compositions. More re-                      about the scripts of a code generator, and helps developers
cently, in [17], Santiago et al. introduced iTrace, a tool that                 to identify maintenance hotspots that answer to platform-
uses a transformation-enrichment strategy, similar to Jouault’s                 evolution scenarios. In [22], we presented a general conceptual
proposal in [18], to collect traceability models at runtime.                    framework, generalizable to all rule-based and template-based
Nevertheless, to the best of our knowledge, current proposals                   model-transformation compositions, that formalizes how to
fail to provide comprehensive tools that support end-to-end                     collect and model traceability information in model-based
platform-evolution analysis, including analysis of the modi-                    code generators. In [23], we showcased ChainTracker as
fied generated code and collection of traceability information                  an integrated tool that implemented our generalizable frame-
from both model-to-model and model-to-text transformations.                     work using static-analysis techniques. We have now further
Furthermore, current proposals fail to provide effective tools                  enhanced ChainTracker to deal with complex model-to-model
that present the traceability information in an interactive                     and model-to-text transformation execution semantics that
and integrated tool, effectively supporting developers in the                   heavily rely on non-trivial OCL expressions [24]. The most
exploration of generation architectures.                                        recent incarnation of ChainTracker uses natural-language
   In summary, most of the existing proposals support very                      processing techniques to collect traceability information in
specific maintenance and construction scenarios. Furthermore,                   a lightweight and generalisable fashion for rule-based and
they often provide theoretical frameworks with demonstrative                    template based transformation languages built-in OCL. The
examples, rather than generic tools than can be shipped                         purpose of this paper is to showcase how ChainTracker pro-
and used by developers in fully-featured model-based code                       vides a comprehensible analysis environment to solve real
generators.                                                                     software-engineering tasks that developers have to complete
                                                                                during the construction of model-based code generators.
                    III. C HAIN T RACKER
  Model-based code-generators are complex; they are built                               IV. S OLVING D EVELOPERS ’ TASKS U SING
using multiple technology platforms including language work-                                         C HAIN T RACKER
benches that allow the definition of domain-specific languages                    ChainTracker is conceived to address three types of
[19], rule-based transformation languages that enable the                       software-engineering tasks around model-based code gener-
  Fig. 2. ChainTracker - Main Screen (1) Transformation-composition Overview; (2) Transformation Script Viewers; (3) Metamodel Information Tables


                                                                           to-text transformations, but also to project the visualizations
                                                                           into the analyzed source-scripts using code-highlighters, thus
                                                                           isolating pieces of code of interest (Figure 1.2)
                                                                              Information summarization tasks require developers to
                                                                           measure generic information from the code-generation archi-
                                                                           tecture to identify branches of a transformation composition,
                                                                           quantify the coverage of a model transformation, and measure
                                                                           the size of the underlying metamodels. Summarizing infor-
                                                                           mation about the code-generator enables developers to assess
                                                                           and, potentially, optimize its overall design and correctness
                                                                           [4]. Figure 2 presents ChainTracker’s Overview mode, in
                                                                           which traceability information is used to provide a bird’s-eye-
                                                                           view of the transformation composition. This view enables
          Fig. 3. ChainTracker - Metamodel Coverage Metrics                developers to abstract the complexity of individual and isolated
                                                                           transformation scripts into a single picture that summarizes
                                                                           the architecture of a given generation architecture. The blue
ators: 1. information discovery, 2. information summarization,             nodes represent source and target artifacts of transformations
and 3. information filtering and isolation. Without Chain-                 (metamodels, in the case of model-to-model transformations,
Tracker, these tasks have to be performed manually over                    and text files, in the case of model-to-text transformations) and
transformation-source scripts [11].                                        the edges represent transformation modules that operate over
   Information discovery tasks involve locating individual                 them.
elements of the code-generator’s architecture, i.e., individual               Developers can click on the edges to pinpoint transformation
metamodel elements, transformation rules, and collections of               rules that live inside of specific transformation branch or mod-
transformation bindings, inside the generator’s source scripts.            ule modules (Figure 2 - yellow "sticky notes"). Furthermore,
The developer’s intent when performing this family of tasks is             developers can zoom into a branch of interest (as shown in Fig-
to explore the code generator to identify its major components,            ure 1). By clicking on individual nodes, developers can access
and to understand how the underlying transformation scripts                summarized information about the coverage of a metamodel
are organized form a static point of view.                                 at different stages of the composition (see Figure 2). Coverage
   As a concrete example, let us briefly discuss PhyDSL, a                 information is important since it allows developers to assess
model-based code generator for physics-based games [25][26].               which parts of the source/target model elements have not been
Figure 1 illustrates how ChainTracker uses the traceability                used in the generation of code, thus needing to be removed
information of PhyDSL to enable the investigation of how                   or included in the scope of the transformation modules [14].
source-metamodel elements are transformed into different                   Maximizing the coverage of model transformations makes
intermediate metamodels (including how their attributes are                transformation modules less convoluted and less error prone
being manipulated by transformation rules) and into final                  while, at the same time, freeing metamodels from unused
textual files. ChainTracker enables developers to not only                 semantic constructs. In ChainTracker, coverage metrics are
explore the visualizations of the model-to-model and model-                summarized in contextual pie-charts, where the in-coverage
metric reflects on the percentage of elements in a metamodel                     [2] K. Czarnecki, “Generative programming: Methods, techniques, and
that are effectively targeted by transformation bindings in                          applications tutorial abstract,” Software Reuse: Methods, Techniques, and
                                                                                     Tools, pp. 477–503, 2002.
the composition, and the out-coverage metric represents the                      [3] M. Mernik, J. Heering, and A. M. Sloane, “When and how to develop
percentage of elements in a metamodel used as a source in                            domain-specific languages,” ACM computing surveys (CSUR), vol. 37,
transformation bindings to either generate code, or to create an                     no. 4, pp. 316–344, 2005.
                                                                                 [4] A. Kleppe, “First european workshop on composition of model trans-
intermediate model by the transformation-composition under                           formations - cmt 2006,” Technical Report TR-CTIT-06-34, 2006.
analysis.                                                                        [5] K. Czarnecki and S. Helsen, “Classification of model transformation ap-
   Information filtering and isolation tasks involve connecting                      proaches,” in Proceedings of the 2nd OOPSLA Workshop on Generative
                                                                                     Techniques in the Context of the Model Driven Architecture, vol. 45,
and isolating elements of the code-generation architecture,                          no. 3. Citeseer, 2003, pp. 1–17.
in order to find relationships between metamodel elements,                       [6] R. France and B. Rumpe, “Model-driven development of complex
metamodel attributes, transformation bindings, and generated                         software: A research roadmap,” in 2007 Future of Software Engineering.
                                                                                     IEEE Computer Society, 2007, pp. 37–54.
lines of code. These tasks are performed when developers are                     [7] J. Hutchinson, J. Whittle, M. Rouncefield, and S. Kristoffersen, “Em-
assessing the impact of platform-evolution scenarios. Chain-                         pirical assessment of mde in industry,” in Proceedings of the 33rd
Tracker includes a variety of filtering mechanism to isolate                         International Conference on Software Engineering. ACM, 2011.
                                                                                 [8] A. Van Deursen, E. Visser, and J. Warmer, “Model-driven software evo-
metamodel elements and trace how elements relate across the                          lution: A research agenda,” in Proceedings 1st International Workshop
end-to-end transformation chains, including domain-specific                          on Model-Driven Software Evolution, 2007, pp. 41–49.
models, intermediate metamodels, and generated source-code                       [9] K. Bennett and V. Rajlich, “Software maintenance and evolution: a
                                                                                     roadmap,” in Proceedings of the Conference on the Future of Software
files (see Figure 1, at 4.a and 4.b). We are currently extending                     Engineering. ACM, 2000, pp. 73–87.
ChainTracker to include symbolic and static analysis of                         [10] V. Guana and E. Stroulia, “Backward propagation of code refinements
generated code, in order to automatically suggest when and                           on transformational code generation environments,” in Traceability in
                                                                                     Emerging Forms of Software Engineering (TEFSE), 2013 International
how refined portions of generated code need to be backwardly                         Workshop on, 2013, pp. 55–60.
propagated to the code-generators, using the traceability in-                   [11] V. Guana, “Supporting maintenance tasks on transformational code
formation already collected and visualized in ChainTracker.                          generation environments,” in Proceedings of the 2013 International
                                                                                     Conference on Software Engineering. IEEE Press, 2013.
In http:// hypatia.cs.ualberta.ca/ ~guana/ chaintracker.html you                [12] M. van Amstel, A. Serebrenik, and M. van den Brand, “Visualizing
can find a video that showcases a developer conducting a                             traceability in model transformation compositions,” in Pre-proceedings
variety of the aforementioned tasks using ChainTracker.                              of the First Workshop on Composition and Evolution of Model Trans-
                                                                                     formations, 2011.
                          V. C ONCLUSIONS                                       [13] J. von Pilgrim, B. Vanhooff, I. Schulz-Gerlach, and Y. Berbers, “Con-
                                                                                     structing and visualizing transformation chains,” in Model Driven
   In this paper, we presented ChainTracker, a traceability                          Architecture–Foundations and Applications. Springer, 2008.
                                                                                [14] J. Wang, S.-K. Kim, and D. Carrington, “Verifying metamodel coverage
collection and visualization analysis environment for model-                         of model transformations,” in Software Engineering Conference, 2006.
based code generators. ChainTracker enables developers to                            Australian. IEEE, 2006, pp. 10–pp.
solve three types of software-engineering tasks around model-                   [15] L. Kuzniarz, J. L. Sourrouille, and M. Staron, “Workshop on quality in
                                                                                     modeling,” 2007.
based code generators: 1. information discovery, 2. information                 [16] J. Gray, Y. Lin, and J. Zhang, “Automating change evolution in model-
summarization, and 3. information filtering and isolation,                           driven engineering,” Computer, vol. 39, no. 2, pp. 51–58, 2006.
when dealing with the platform evolution of code generators                     [17] I. Santiago, J. M. Vara, M. V. de Castro, and E. Marcos, “Towards the
                                                                                     effective use of traceability in model-driven engineering projects,” in
and the analysis code-generation architectures. The novelty                          Conceptual Modeling. Springer, 2013, pp. 429–437.
of our work is twofold. First, in ChainTracker traceability                     [18] F. Jouault, “Loosely coupled traceability for atl,” in Proceedings of
information is used to reduce the cognitive challenges de-                           the European Conference on Model Driven Architecture (ECMDA)
                                                                                     workshop on traceability, Nuremberg, Germany, vol. 91. Citeseer, 2005.
velopers face when using disparate model-driven engineering                     [19] M. Völter and E. Visser, “Language extension and composition with
technologies. Second, ChainTracker is an integrated environ-                         language workbenches,” in Proceedings of the ACM international con-
ment that uses traceability information to allow developers                          ference companion on Object oriented programming systems languages
                                                                                     and applications companion. ACM, 2010, pp. 301–304.
interactively explore model-transformation scripts. Our future                  [20] F. Jouault and I. Kurtev, “Transforming models with atl,” in Satellite
research agenda aims at conducting empirical studies with                            Events at the MoDELS 2005 Conference. Springer, pp. 128–138.
developers using ChainTracker, to accurately validate how                       [21] J. Musset, É. Juliot, S. Lacrampe, W. Piers, C. Brun, L. Goubet,
                                                                                     Y. Lussaud, and F. Allilaire, “Acceleo user guide,” 2006.
our tool and traceability collection techniques help developers                 [22] V. Guana, K. Gaboriau, and E. Stroulia, “Chaintracker: Towards a
when using model-driven engineering technologies in real                             comprehensive tool for building code-generation environments,” in Pro-
code generators.                                                                     ceedings of the 2014 International Conference on Software Maintenance
                                                                                     and Evolution (ICSME). IEEE Press, 2014.
                       ACKNOWLEDGEMENTS                                         [23] V. Guana and E. Stroulia, “Chaintracker, a model-transformation trace
                                                                                     analysis tool for code-generation environments,” in Theory and Practice
  This work was supported by The Killam Trust, NSERC (the                            of Model Transformations. Springer, 2014, pp. 146–153.
Discovery and the IRC program), the GRAND NCE and IBM                           [24] J. Warmer and A. Kleppe, The object constraint language: getting your
                                                                                     models ready for MDA. Addison-Wesley Professional, 2003.
Canada.                                                                         [25] V. Guana, E. Stroulia, and V. Nguyen, “Building a game engine: A tale
                                                                                     of modern model-driven engineering,” in Fourth International Workshop
                             R EFERENCES                                             on Games and Software Engineering (GAS 2015), 2015.
 [1] M. Voelter, S. Benz, C. Dietrich, B. Engelmann, M. Helander, L. C. Kats,   [26] V. Guana and E. Stroulia, “Phydsl: A code-generation environment for
     E. Visser, and G. Wachsmuth, DSL Engineering-Designing, Implement-              2d physics-based games,” in 2014 IEEE Games, Entertainment, and
     ing and Using Domain-Specific Languages. dslbook. org, 2013.                    Media Conference (IEEE GEM), 2014.