A Comparative Look at Model Transformation Languages
Total Page:16
File Type:pdf, Size:1020Kb
A comparative look at model transformation languages Matthew Stephan Andrew Stevenson Queen’s University Queen’s University Kingston, Canada Kingston, Canada [email protected] [email protected] ABSTRACT Model-driven development(MDD) is a paradigm in which Model-driven development is an emerging area in software software is constructed in a model-centric fashion. Models development that provides a way to express system require- are the main artifacts of interest to stakeholders and system ments and architecture at a high level of abstraction through developers and the underlying code that implements the models. It involves using these models as the primary system is generated from these models. In a perfect model- artifacts during the development process. One aspect that centric development project, models are the only elements is holding back MDD from more wide-spread adoption is that change as the implementing software code is generated the lack of a well established and easy way of performing and updated automatically. model to model (M2M) transformations. We propose to explore and compare popular M2M model transformation One large area of importance in MDD is the notion of model languages in existence: EMT , Kermeta, and ATL. Each transformations, that is, the ability to transform one model of these languages support transformation of Ecore models to another through modifying the model itself or by creating within the Eclipse Modeling Framework (EMF). We attempt a new version of the model. Model transformations can be to implement the same transformation rule on identical meta split into two categories, model-to-model transformations models in each of these languages to achieve the appropriate and model-to-text/code transformation [5]. The model- transformed model. We provide our observations in using to-text transformation task, sometimes referred to as code each tool to perform the transformation and comment on generation, is relatively more mature and explored compared each language/tool's expressive power, ease of use, and to model-to-model(M2M) transformations. modularity. We conclude by noting that ATL is our language / tool of choice because it strikes a balance Progressing in the area of model-to-model transformations between ease of use and expressive power and still allows is crucial in continuing to foster the adoption of MDD as for modularity. We believe this, in conjunction with ATL's noted in [5, 9] as these are important operations. Although role in the official Eclipse M2M project will lead to wide- there are many classifications of model transformation ap- spread use of ATL and, hopefully, a step forward in M2M proaches [3], all with much promise, it is still unclear which transformations. approach is the best for M2M transformations in practice or if some are best suited to specific contexts. Categories and Subject Descriptors D.2.12 [Software Engineering]: [Interface definition lan- In this paper, we utilize and evaluate 3 fairly well known guages] M2M model transformation languages each belonging to a different category of M2M as defined in [3]. The languages that we compare, along with their corresponding categories, General Terms are EMF Model Transformation Framework [1], a graph- Languages transformation based approach; KerMeta [7], a direct- manipulation approach; and Atlas [6] (ATL), which is a Keywords hybrid approach and is part of the official Eclipse M2M Model transformations, Model-driven development, model project. transformation languages, meta modeling Section 2 begins by first providing a brief summary of M2M 1. INTRODUCTION transformations and Eclipse Modeling Framework (EMF) Ecore models and continues with the M2M approaches that we discuss in the remainder of the paper. Section 3 outlines the procedure that we will follow in order to perform the comparison, which includes a discussion of the M2M transformation that will be attempted on all 3 languages and the various dimensions that the 3 approaches will be compared on. Section 4 presents the observations we make when using each of the respective approaches to accomplish the M2M transformation. The paper concludes with Section 5, in which we summarize our observations and provides many useful built-in collection operations such chose which tool we consider the best given our criteria. as iterators, filters, and common set operators. An ATL program is composed of rules that indicate how model 2. BACKGROUND elements are identified and subsequently modified in order This section provides brief background information on M2M to obtain the target model. transformations, EMF Ecore, and the three languages we use. Figure 1 illustrates a sample rule we have taken from the ATL user guide. The rule has a source and a target metamodel, MMAuthor and MMPerson, respectively. The 2.1 M2M Transformations Authors within the MMAuthor metamodel, denoted by !Au- M2M transformation refers to the process of modifying a thor following the source Metamodel name, are represented model to create either a new model or update itself [8]. by the variable a. Persons in the target metamodel, bound Generally model transformation can be seen as an operation to variable p, are new model objects that have their features that takes existing model elements, follows some guidelines name and surname set to name and surname found in the or rules as to what should be modified and how it should corresponding Author object. modified, and then produces either an entirely new model containing appropriate elements or the modified version of There are three types of rules in ATL: Matched rules, such the model with the new/modified elements. Model-to-model as the one presented in Figure 1 that are automatically transformations involve the process of going from platform- called; lazy rules, which are ones only executed when independent models (PIM)s to either other PIMs or from called by another rule; and called rules, which do not PIMs to platform-specific models (PSM)s not in the form of include a source pattern and may contain optional local code. variables/parameters. There are two types of execution modes in ATL: the normal mode and the refining mode. The 2.2 Ecore refining mode is used to focus on specific transformations Ecore [10] is Eclipse's implementation of the Essential Meta- the program, for example, to transform one source model Object Facility (EMOF). It provides the M2 layer, which is element into one target model element and focus while the Ecore language that allows modelers to develop meta leaving the rest implicitly copied. models, called Ecore models. Ecore models are the M1 layer and can be used to specify systems or a family of systems r u l e Author f that can later be instantiated (M0 layer). That is, Eclipse's from implementation allows users to develop Ecore meta models a : MMAuthor ! Author (M1 layer) to allow for instantiation of system models (M0 to p : MMPerson!Person ( layer) that can be developed within an Eclipse application. name <− a . name , A completed Ecore (meta) model allows for code generation, surname <− a . surname validation, and instantiation of Ecore instance models. It is ) widely used in both industry and research and all three of g the model transformation languages discussed in this project work with Ecore models. Figure 1: Sample ATL Rule 2.3 Languages Used 2.3.2 EMF Model Transformation Framework The three modeling transformation languages used by us The EMF Model Transformation (EMT) framework pro- for this project all work with Ecore models as we figure vides an entirely graphical interface to describe in-place this will provide a common foundation for comparison. We transformation rules on an Ecore model. It includes a attempt to select languages that are prevalent in research compiler and a code generator so that the transformations and industry, based on quantity of documentation and other created within it can be reused. EMT is built upon information sources, and that are different enough that AGG [11], which is a graph transformation tool. a comparison will exhibit the benefits and drawbacks of various approaches to achieving M2M transformation. As shown in Figure 2, the Eclipse editor is divided into Left- Hand Side (LHS) and Right-Hand Side (RHS) panes that 2.3.1 Atlas Transformation Language show how model elements are structured before and after the The ATLAS Transformation Language (ATL) is one of transformation. Optionally, a negative application condition three transformation engines within the Eclipse Model- (NAC) pane can be used to show the one or more situations To-Model subproject, which, itself, is part of the Eclipse where a rule should not be applied. Model elements in Modeling Project. The other two engines are based on the LHS can be mapped to corresponding elements in the the Query/View/Transformation (QVT) standard set by the RHS and NAC section to indicate their identity, and are Object Management Group, but their implementations are represented visually by having the same colour in those still relatively immature so we consider them out of scope panes. Unmapped elements in the LHS are deleted in the for the work in this paper. transformation and unmapped elements in the RHS are created. The example in Figure 2, is an example of a ATL is a ruled-based domain-specific language that de- transformation that will move all Eclasses with name equal scribes transformations from one Ecore metamodel to an- to 'n' to the package with its name equal to 'p'. The other Ecore metamodel. It supports an interesting mix NAC pane indicates that any packages already containing of declarative and imperative language paradigms, and the Eclass to be moved can be ignored. EMT has been c l a s s Class2RDBMS f /∗∗ The trace of the transformation ∗/ reference class2table : Trace<Class , Table > /∗∗ Set of keys of the output model ∗/ reference fkeys : Collection <FKey> operation transform(inputModel : ClassModel ) : RDBMSModel i s do // Initialize the trace class2table := Trace<Class , Table >.new class2table .create f k e y s := Set<FKey>.new r e s u l t := RDBMSModel .