Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Quality Assessment of Xtend Model Transformations Phu H. Nguyen, [email protected] Supervisor: Tutor: Prof. dr. Mark van den Brand Ir. Marcel van Amstel Agenda • • • • • • • • Introduction Project goal Overview of Xtend model transformations Metrics How to extract data from Xtend model transformations Tools Case studies Conclusions / Department of Mathematics and Computer Science 24-5-2017 PAGE 1 Introduction • Model Driven Software Development (MDSD): the next level of software development • High level design models at the heart of the development process • Software development automation • Benefits : Productivity, agility, reliability • MDSD world: • Domain-specific languages (DSL) • Model transformations M2M (Model-to-Model) • Model transformations M2T (Model-to-Text) / Department of Mathematics and Computer Science 24-5-2017 PAGE 2 How MDSD works M2M : Transform models to models • ATL - the Atlas Transformation Language • QVT (Operational) - An implementation of OMG’s spec. • Xtend – openArchitechtureWare (oAW) ’s transformation language (also used for other tasks within oAW) / Department of Mathematics and Computer Science 24-5-2017 PAGE 4 Model transformations M2M • Is there a methodology for developing model transformations with high quality? • Need of assessing the quality of model transformations • Quality assessment of model transformations: • • • • ASF+SDF: enabled ATL: enabled QVT: ? Xtend: ? / Department of Mathematics and Computer Science 24-5-2017 PAGE 5 Project goal • The main goal is to enable quality assessment for Xtend model transformations by means of metrics. • Approach: assessing the internal quality of model transformations by extracting metrics from the model transformations directly. / Department of Mathematics and Computer Science 24-5-2017 PAGE 6 Sub-goals • Four sub-goals: • Discover the details behind Xtend model transformations. • Establish a metrics suite enables quality measurement of Xtend model transformations. • Develop a tool that enables automatic calculation of those metrics. • Perform case studies to validate the results. / Department of Mathematics and Computer Science 24-5-2017 PAGE 7 oAW & Xtend model transformations • An integrated, tested, one-stop toolkit for MDSD • oAW essentially makes it possible to process code generators for any type of model. • Any type of source code can be generated from the model sources. / Department of Mathematics and Computer Science 24-5-2017 PAGE 8 Features of oAW • The most important features of oAW include: • • • • • support of various modeling tools support of EMF (Eclipse Modeling Framework) model-to-model transformations model-to-code-transformations eclipse integration • Migrated to Eclipse: • http://www.eclipse.org/workinggroups/oaw/ − Xpand/Xtend/Check / Department of Mathematics and Computer Science 24-5-2017 PAGE 9 oAW components • • • • • • • Metamodel definition: EMF, UML model Graphical model editor: Eclipse GMF Textual model editor: Xtext Model transformation: Xtend Model validation: Check Code generation: Xpand Metamodel extension: Xtext / Department of Mathematics and Computer Science 24-5-2017 PAGE 10 Xtend model transformations in oAW Xtend • OCL-like expression language used throughout oAW • Can be used in constraint checks, model transformations and generators • Add “methods” to meta types (Java calls are possible if necessary) • path expressions, set operations, (some) higher order functions • Polymorphism (multiple dispatch) • Tool support (syntax highlighting, code completion, debugger) Xtend model transformations… … are defined in extension files (*.ext): • Import statements • Import name spaces (meta-models) • Import (reexport) built-in libraries or another extend files • Create extensions • Expression extensions • Java extensions / Department of Mathematics and Computer Science 24-5-2017 PAGE 13 Xtend model transformations Xtend has some special support for M2M transformations • Create-Extensions are used to create a new instance • A new element is created only once for the same set of parameters • Cached Extension can be used for perfomence improvements • The same value is returned each time the extension is called with the same set of parameters • Several utility extensions (built-in libraries) for naming, tracing, debugging, cloning, … / Department of Mathematics and Computer Science 24-5-2017 PAGE 14 Book → Publication • Rules to transform a Book model to a Publication model: • Each Book instance → a Publication instance • The title of a Book → the title of a Publication • The total number of pages of a Publication is the sum of the pages of the Chapters of a Book. / Department of Mathematics and Computer Science 24-5-2017 PAGE 15 Book → Publication / Department of Mathematics and Computer Science 24-5-2017 PAGE 16 Book → Publication: Extension File / Department of Mathematics and Computer Science 24-5-2017 PAGE 17 Metrics for Xtend model transformations • A set of metrics has been proposed for enabling quality assessment of Xtend model transformations • These metrics are specific for Xtend • Metric categories: • Extension metrics • Dependency metrics • Other metrics • Two types of metric: • Metrics that are measured over the entire transformation • Metrics that are measured on a smaller scale (per extension file, per extension… / Department of Mathematics and Computer Science 24-5-2017 PAGE 18 Metrics for Xtend model transformations Extension metrics • # Extensions • # Create/Expression/Java Extensions • # Private/Public/Cached Extensions • • • • • • • # Extensions per Extension File # Extensions with Parameter # Overloaded Extensions # Parameters per Extension # Unused Parameters per Extension Cyclomatic Complexity per Extension … / Department of Mathematics and Computer Science 24-5-2017 PAGE 19 Metrics for Xtend model transformations Dependency metrics • # Imported Standard Libraries per Extension File • # Imported Extension Files per Extension File • # Calls to Extensions in Standard Libraries per Extension • # Extension Calls per Extension • # Internal Extension Calls per Extension • # External Extension Calls per Extension • # Usages per Extension • … / Department of Mathematics and Computer Science 24-5-2017 PAGE 20 Metrics for Xtend model transformations Other metrics • # Extension Files • # Imported Namespaces (Metamodels) per Extension File • # Arounds • # Checks / Department of Mathematics and Computer Science 24-5-2017 PAGE 21 How the XtendParser works • The XtendParser constructs an Abstract Syntax Tree while parsing an Xtend file. • The transformation functions after parsing *.ext files are represented as an in-memory model consisting of POJO’s (Plain Old Java Objects). • The basic type is org.eclipse.internal.xtend.expression.ast.SyntaxElement / Department of Mathematics and Computer Science 24-5-2017 PAGE 22 Xtend AST Metric Extractor Tools • Design requirements • Input: Extension files • Output: Metrics − New metrics can be defined easily − It is possible to quickly implement the calculation of a new metric Metric Extractor Tools • In order to calculate the metrics, we need to extract data from the Xtend AST(s) to store in a well defined data model • “data” means all elements of Xtend model transformations • A well defined data model = data can be stored easily and metrics can be calculated easily. Metric Extractor Tools • Which data model? • Relational data model: No • Java Objects − Store data easily: The Xtend AST consists of Java Objects − Easily implementing metrics calculation in Java • XML − Store data of the Xtend AST in XML − Easily calculating metrics by using Xpath, Xquery Metric Extractor Tool 1 – M2M QA • Data model = Java Objects Class diagram of Java objects Class diagram of Data Extractor Simple Metrics Aggregate Metrics GUI for M2M QA • Implement GUI, as a jar file • Implement as an Eclipse plugin / Department of Mathematics and Computer Science 24-5-2017 PAGE 32 Metric Extractor Tool 2 • • • • Data model = XML Native XML database eXist XPath and XQuery are used for querying the XML data GUI: A web application • Java, JavaBeans, JSP/Servlet and Java Server Faces. • Apache HTTP server Apache Tomcat 7.0. / Department of Mathematics and Computer Science 24-5-2017 PAGE 33 Metric Extractor Tool 2 DTD <!ELEMENT xtendPrj (extendFile*)> <!ATTLIST xtendPrj prjName CDATA #REQUIRED> <!ATTLIST xtendPrj prjDir CDATA #REQUIRED> <!ATTLIST xtendPrj rootExtFile CDATA #REQUIRED> <!ELEMENT extendFile (importedNamespaces|importedExtFiles|extensions|arounds|checks)*> <!ATTLIST extendFile extFileName CDATA #REQUIRED> <!ELEMENT importedNamespaces (namespace*)> <!ELEMENT namespace (#PCDATA)> <!ELEMENT importedExtFiles (extFileName*)> <!ELEMENT extFileName (#PCDATA)> <!ATTLIST extFileName reexported CDATA #REQUIRED> <!ELEMENT extensions (extension*)> <!ELEMENT extension (extName|qualifiedName|parameters|returnType|extBody)*> / Department of Mathematics and Computer Science 24-5-2017 PAGE 35 XML <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xtendPrj SYSTEM "xtendPrj.dtd"> <xtendPrj prjName="" prjDir="../my.slco.project/src/" rootExtFile="../my.slco.project/src/slco2nqx/Bi2Uni.ext"> <extendFile extFileName="../my.slco.project/src/slco2nqx/Bi2Uni.ext"> <importedNamespaces> <namespace>slco</namespace> <namespace>channels</namespace> </importedNamespaces> <importedExtFiles> / Department of Mathematics and Computer Science 24-5-2017 PAGE 36 Xpath, XQuery # Extensions per Extension File: This metric counts the number of extensions per extension file. element { "result" } { for $extFile in doc("xtendM2M/Bi2Uni.xml")//extendFile return element { "extCountPerExtFile" } { count(for $ext in $extFile//extension return $ext) } / Department of Mathematics and Computer Science 24-5-2017 PAGE 37 M2M QA Web Application • • • • • Upload (zipped) extend files of an Xtend project Browse data Metrics calculation Search Download reports / Department of Mathematics and Computer Science 24-5-2017 PAGE 38 M2M QA Web Application / Department of Mathematics and Computer Science 24-5-2017 PAGE 39 Summary • A set of metrics has been established to enabling quality assessment of Xtend model transformations • Extension file(s) are parsed by the XtendParser to get the corresponding AST(s) • 2 types of data model => 2 tools • All the metrics can be automatically calculated by these two tools • The results extracted from both tools are the same / Department of Mathematics and Computer Science 24-5-2017 PAGE 40 The end. / Department of Mathematics and Computer Science 24-5-2017 PAGE 41