
Model Transformations @ Google Model Transformations An overview Pierre-Alain Muller INRIA [email protected] Artist2 Summer School 05 Pierre-Alain Muller 2 Outline Principles of Model-Driven Engineering ►MDE basic principles ►A kind of (software) development approach ►What is a model-transformation? ►Models as first class entities ►Typology of model-transformations ►Everything is a model ►Examples of transformations ►A model conforms to an other model (meta- model) ►A model transformation takes models and produces models ►A model-transformation is a model Artist2 Summer School 05 Pierre-Alain Muller 3 Artist2 Summer School 05 Pierre-Alain Muller 4 MDA = MDE à la OMG Meta-modeling architecture Computer ►OMG, Object Management Group M3 Meta-Metamodel ►MDA, Model-Driven Architecture ►PIM, Platform Independent Model M2 Metamodel ►PSM, Platform Specific Model M3 M2 M1 M0 M1 Model ►(PDM, Platform Description Model) ►Transformation (PIM, PDM) -> PSM M0 Computer Manifestation RFP MOF Q/V/T Query, Views, Transformations RFP MOF to Text Real World Often misleading Artist2 Summer School 05 Pierre-Alain Muller 5 Artist2 Summer School 05 Pierre-Alain Muller 6 1 Motivation But also ►Model transformation is key to Model-Driven ►Refining models Engineering ►Reverse engineering (code to models) Automation of the transition from Business Automation of the transition from Business ►Generating new views models to Implementation models ►Applying design patterns Business ►Refactoring models Transformation Implementation Description Platform Artist2 Summer School 05 Pierre-Alain Muller 7 Artist2 Summer School 05 Pierre-Alain Muller 8 Typical scope for transformations Related fields Program transformation and compiler techniques Meta-programming techniques Graph rewriting techniques Artist2 Summer School 05 Pierre-Alain Muller 9 Artist2 Summer School 05 Pierre-Alain Muller 10 MOF 2.0 Transformation Architecture Queries/Views/Transformations RFP Transformation Architecture ► Define a language for querying MOF models Define Transformation ► Define a language for transformation definitions Meta-model A Meta-model B ► Allow for the creation of views of a model ► Ensure that the transformation language is declarative and expresses complete Conforms To Transformation Conforms To transformations ► Ensure that incremental changes to source models can be immediately propagated to the target Model A Model B models Apply Transformation ► Express all new languages as MOF models Artist2 Summer School 05 Pierre-Alain Muller 11 Artist2 Summer School 05 Pierre-Alain Muller 12 2 Typical Example Transformations as models From UML to RDBMS ►Composition of transformations ►Transformation of transformations Meta-Meta-model Transformation Transformation Meta-model Meta-model Model Transformation Model Artist2 Summer School 05 Pierre-Alain Muller 13 Artist2 Summer School 05 Pierre-Alain Muller 14 Toward Model-Transformations General purpose language approach ►CRUD on model elements ► Java, VB, C++, C#,... Your favorite language! ► Currently available in the tools via APIs Create, Read, Update, Delete ► No overhead to learn a new language ► Tool support to write the transformations ►Transformation rules written in Tool support to write the transformations General purpose languages + API Intermediate transformation language => Monsieur Jourdain’s approach Dedicated Model-Transformation languages ► It’s going to be challenging to do better! Artist2 Summer School 05 Pierre-Alain Muller 15 Artist2 Summer School 05 Pierre-Alain Muller 16 Action Language Intermediate transformation language ►Use a general purpose action language ► Typically XML based Better navigation facility (associations) But XML (XMI) is verbose Get access to the types defined in the models ► XSLT can be used to transform XML trees into Procedural rule description other (XML) (trees) More batch than interactive Parameters are passed by values XSLT transformations are not really easy to maintain ► Better for simple transformations Artist2 Summer School 05 Pierre-Alain Muller 17 Artist2 Summer School 05 Pierre-Alain Muller 18 3 Example of XSLT transformation Dedicated Transformation Language ►Kind of DSL for transformation If isSynchronous ►Simplify development and maintenance of Do this model-transformations ►Higher expression power Else ►Enhanced structuration Composition of rules Do that Interoperability Artist2 Summer School 05 Pierre-Alain Muller 19 Artist2 Summer School 05 Pierre-Alain Muller 20 Dedicated transformation languages Query ►Terminology ►An expression evaluated over a model ►Features of model transformations Returns one or more instances of types defined either in the source model or by the query language ►OCL is an example of a query language Artist2 Summer School 05 Pierre-Alain Muller 21 Artist2 Summer School 05 Pierre-Alain Muller 22 Examples of OCL queries View ►A view is a model that is completely derived OCL from another model Standard Lib Type The meta-model of the view is typically not the same as the meta-model of the source Query: Has Pierre-Alain Muller sent a message about a given subject s? s.post->exists (author.name='Muller' and author.firstname='Pierre-Alain') Meta-Model A Meta-Model A’ Query: Knowing that there is only one subject about QVT, I want to retrieve it. Model Transformation View Subject.allInstances()->any (title = ‘QVT’) Model Type Artist2 Summer School 05 Pierre-Alain Muller 23 Artist2 Summer School 05 Pierre-Alain Muller 24 4 Transformation Q vs V vs T ►A transformation generates a target model ►A query is a restricted kind of view from a source model Source Target ►A view is a restricted kind of transformation Transformation Model Model The target model cannot be modified independently of the source model May be bi-directional ►A transformation generates a target model from a source model Artist2 Summer School 05 Pierre-Alain Muller 25 Artist2 Summer School 05 Pierre-Alain Muller 26 Declarative Imperative ►Declarative languages describe relationships ►Any programming language that specifies between variables in terms of functions or explicit manipulation of the state of the inference rules and the language executor computer system, not to be confused with a (interpreter or compiler) applies some fixed procedural language algorithm to these relations to produce a result Artist2 Summer School 05 Pierre-Alain Muller 27 Artist2 Summer School 05 Pierre-Alain Muller 28 Declarative vs. Imperative Style Execution Strategy ► Declarative (what to do) ►Invocation of the transformation rules Invariant relations between source and target models Explicit, via invocation operations (Java like) Implicit, based on contextcontext and rules’ signature ► Imperative (how to do it) How to derive a target from a source (Prolog like) ► May be combined via pre- and post-conditions Declarative Declarative Pre-Condition Imperative Rule Post-Condition Artist2 Summer School 05 Pierre-Alain Muller 29 Artist2 Summer School 05 Pierre-Alain Muller 30 5 Trace Rule ►Trace associates one (or more) target ►Rules are the units in which transformations element with the source elements that lead are defined to its creation A rule is responsible for transforming a For Round-trip development particular selection of the source model to the Incremental propagation corresponding target model elements. ►Rules may be able to match elements based on the trace without knowing the rules that created the trace Artist2 Summer School 05 Pierre-Alain Muller 31 Artist2 Summer School 05 Pierre-Alain Muller 32 Declaration Implementation ►A declaration is a specification of a relation ►An implementation is an imperative between elements in the LHS and RHS specification of how to create target model models elements from source model elements An implementation explicitly constructs elements in the target model Implementations are typically directed Artist2 Summer School 05 Pierre-Alain Muller 33 Artist2 Summer School 05 Pierre-Alain Muller 34 Match Incremental ►A match occurs during the application of a ►A transformation is incremental if individual transformation when elements from the LHS changes in a source model can lead to and/or RHS model are identified as meeting execution of only those rules which match the constraints defined by the declaration of the modified elements a rule A match triggers the creation (or update) of model elements in the target model Artist2 Summer School 05 Pierre-Alain Muller 35 Artist2 Summer School 05 Pierre-Alain Muller 36 6 Classification of model transformations Model-to-Text Approaches ►Visitor-Based Approaches ►Template-Based Approaches Artist2 Summer School 05 Pierre-Alain Muller 37 Artist2 Summer School 05 Pierre-Alain Muller 38 Model-to-Model Approaches M2T: Visitor-based ►Direct-Manipulation Approaches ►Some visitor mechanisms to traverse the ►Relational Approaches internal representation of a model and write code to a text stream ►Graph-transformation-based Approaches Iterators ►Structure-Driven Approaches Write () ►Hybrid Approaches ►Other Artist2 Summer School 05 Pierre-Alain Muller 39 Artist2 Summer School 05 Pierre-Alain Muller 40 M2T: Template-Based M2T : Template ►A template consists of the target text containing slices of meta-code to access information from the source and to perform text selection and iterative expansion The structure of a template resembles closely the text to be generated Textual templates are independent of the target language and simplify the generation of any textual artefacts Artist2 Summer
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages11 Page
-
File Size-