Evaluation of Kermeta on Graph Transformation Problems Naouel Moha, Sagar Sen, Cyril Faucher, Olivier Barais, Jean-Marc J´Ez´Equel
Total Page:16
File Type:pdf, Size:1020Kb
View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by HAL-Rennes 1 Evaluation of Kermeta on Graph Transformation Problems Naouel Moha, Sagar Sen, Cyril Faucher, Olivier Barais, Jean-Marc J´ez´equel To cite this version: Naouel Moha, Sagar Sen, Cyril Faucher, Olivier Barais, Jean-Marc J´ez´equel. Evaluation of Kermeta on Graph Transformation Problems. International Journal on Software Tools for Technology Transfer, Springer Verlag, 2010. <inria-00477521> HAL Id: inria-00477521 https://hal.inria.fr/inria-00477521 Submitted on 29 Apr 2010 HAL is a multi-disciplinary open access L'archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destin´eeau d´ep^otet `ala diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publi´esou non, lished or not. The documents may come from ´emanant des ´etablissements d'enseignement et de teaching and research institutions in France or recherche fran¸caisou ´etrangers,des laboratoires abroad, or from public or private research centers. publics ou priv´es. Software Tools for Technology Transfer manuscript No. (will be inserted by the editor) Evaluation of Kermeta for Solving Graph-based Problems Naouel Moha, Sagar Sen, Cyril Faucher, Olivier Barais, Jean-Marc J´ez´equel IRISA / INRIA Rennes Bretagne Atlantique, e-mail: {moha, ssen, cfaucher, barais, jezequel}@irisa.fr Received: date / Revised version: date Abstract. Kermeta is a meta-language for specifying language implemented on top of the Eclipse Modeling the structure and behavior of graphs of interconnected Framework (EMF) within the Eclipse development en- objects called models. In this paper, we show that Ker- vironment. meta is relatively suitable for solving three graph-based In this paper, we present Kermeta as a suitable lan- problems. First, Kermeta allows the specification of generic guage for solving graph-based problems. We focus on model transformations such as refactorings that we ap- three case studies proposed in the GraBats’08 tool con- ply to different metamodels including Ecore, Java, and test1 that involve specific graph-based problems. Uml. Second, we demonstrate the extensibility of Ker- The first case study consists of applying three well meta to the formal language Alloy using an inter-language known refactorings [6] (Encapsulate Field, Move Method, model transformation. Kermeta uses Alloy to gener- and Pull Up Method) on models of Java programs. In this ate recommendations for completing partially specified paper, we present a generalised approach to model refac- models. Third, we show that the Kermeta compiler achieves toring that is applicable not only to Java programs but better execution time and memory performance com- other metamodels such as Ecore and Uml. We spec- pared to similar graph-based approaches using a com- ify the generic refactorings for various metamodels using mon case study. The three solutions proposed for those the notion of model typing [26], which is an extension of graph-based problems and their evaluation with Ker- object typing in the model-oriented context. meta according to the criteria of genericity, extensibility, The second case study (conference scheduling) high- and performance are the main contribution of the paper. lights the extensibility of Kermeta to external languages, Another contribution is the comparison of these solu- such as the formal specification language Alloy. We tions with those proposed by other graph-based tools. present an inter-language model transformation from Ker- meta to Alloy to complete partial models. In the con- text of the case study, we use Alloy to generate differ- Key words: MDE – Metamodelling – Model Typing ent valid schedules for an unscheduled conference. – Model Transformation – Refactoring – Performance – The third case study is an AntWorld simulation de- Genericity – Extensibility – Alloy monstrating Kermeta performance with regard to exe- cution time and memory usage. The Kermeta to Java / 1 Introduction EMF compiler provides a version of the Kermeta simu- lation achieving better performance compared to similar Model-Driven Engineering (MDE) is a software develop- approaches based on Eclipse and eventually EMF. ment methodology focusing on models as first-class enti- Our contributions are threefold: (1) approaches to ties. Models are sets of objects which types are defined in solve graph-based problems involving these case studies, metamodels. They can also be seen as graphs of objects (2) experiments to evaluate Kermeta in terms of generic- interconnected by relationships. MDE aims to improve ity, extensibility, and performance using these case stud- productivity of developers by maximizing compatibility ies, (3) and a comparison of our approaches with those between systems and platforms and simplifying the pro- proposed by other graph-based tools. cess of design. Kermeta has been developed as a core language for 1 The GraBats’08 tool contest was held during the 4th Inter- an MDE platform. It is an executable metamodelling national Workshop on Graph-Based Tools 2008. 2 Naouel Moha et al.: Evaluation of Kermeta for Solving Graph-based Problems Fig. 1. Kermeta Graphical Interface This article is organized as follows. Section 2 intro- 2.2 Extension of Kermeta duces Kermeta and highlights some of its features in- The first key feature of Kermeta is its ability to extend cluding the notion of model typing. Sections 3, 4, and 5 an existing metamodel with constraints, new structural develop each of the three criteria that characterise Ker- elements (meta-classes, classes, properties, and opera- meta based on the three case studies. Section 6 surveys tions), and functionalities defined with other languages related work. Section 7 concludes and presents future using the aspect keyword. This keyword permits the com- work. position of corresponding code within the underlying metamodel as it was a native element of it. This feature 2 Kermeta offers more flexibility to developers by enabling them to easily manipulate and reuse existing metamodels. The 2.1 Description static composition operator “require” allows defining the- Kermeta is a language for specifying metamodels, mod- se various aspects in separate units and integrating them els, and model transformations that are compliant to the automatically into the metamodel. The composition is Meta Object Facility (MOF) standard [21]. The object- performed statically and the composed metamodel is oriented meta-language MOF supports the definition of type-checked to ensure the safe integration of all units. metamodels in terms of object-oriented structures (pack- This mechanism can be compared to the open class para- ages, classes, properties, and operations). It also pro- digm [5]. Open classes in Kermeta are used to organize vides model-specific constructions such as containments “cross-cutting” concerns separately from their metamodel, and associations between classes. Kermeta extends the a key feature of aspect-oriented programming [12]. Thanks MOF with an imperative action language for specify- to this composition operator, Kermeta remains a ker- ing constraints and operational semantics for metamod- nel platform and safely integrates all concerns around a els [19]. Kermeta is built on top of EMF within the metamodel. Eclipse development environment. The action language Kermeta offers expressions very similar to Object of Kermeta provides mechanisms for dynamic binding, Constraint Language (OCL) expressions [22]. In partic- reflection, and exception handling. It also includes clas- ular, Kermeta includes lexical closures similar to OCL sical control structures such as blocks, conditionals, and iterators on collections such as each, collect, select, or loops. Figure 1 shows the Kermeta graphical interface detect. Moreover, Kermeta also allows the direct impor- within Eclipse. It includes three views: a graphical rep- tation and evaluation of OCL constraints. Pre-conditions resentation of the current metamodel, a Kermeta code and post-conditions can be defined for operations and that applies transformations on the metamodel, and a invariants on classes. tree representation of concepts of one of the two first Kermeta and its framework remain dedicated to mo- views depending on the current view. del processing but provide an easy integration with other In the next paragraphs, we describe two key features languages. Kermeta also allows importing Java classes to of the Kermeta language essential for the comprehension use services such as file input/output or network commu- of the paper: its ability of extension and the notion of nications, which are not available in the Kermeta frame- model typing. work. It is also very useful, for instance, to make models Naouel Moha et al.: Evaluation of Kermeta for Solving Graph-based Problems 3 communicate with existing Java applications. An other a comparison with other graph-based tools2; 6) we end example of integration is the extension to Alloy [9] as with a discussion. presented in Section 4. 3 Genericity 2.3 Model Typing In this section, we present generic model transforma- The second key feature of Kermeta is the notion of model tions in Kermeta based on the notion of model typing. typing [26]. It consists of an extension of object-oriented More precisely, we specify generic refactorings for differ- typing in a model-oriented context: a model transforma- ent metamodels. tion expects some properties in its input model, like a given reference and multiplicity between a class A and a class B; if the instances of A in the input model have no 3.1 Problem Description such reference, this model cannot be processed by the transformation. A model typing is a strategy for using Refactoring has been intensively investigated in the graph models that are subtypes or variants of a required model and model transformation community over the last few in place of it. Model typing permits the detection of type years [16]. However, to the best of our knowledge, there errors early in the design process of model transforma- exists no approach to specify metamodel independent tion. Moreover, it allows more flexible reuse of model generic transformations.