CHART: An Approach for Non Invasive Model Transformation IPA Spring Days, April 18 th , 2012 Maarten de Mol 1 , Arend Rensink 1 , James J. Hunt 2 1 University of Twente, Netherlands 2 Aicas GmbH, Karlsruhe, Germany CHART: An Approach for Non Invasive Graph Transformation
27
Embed
CHART: An Approach for Non Invasive Model Transformation IPA Spring Days, April 18 th, 2012 Maarten de Mol 1, Arend Rensink 1, James J. Hunt 2 1 University.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
CHART: An Approach for Non InvasiveModel Transformation
IPA Spring Days, April 18th, 2012
Maarten de Mol1, Arend Rensink1, James J. Hunt2
1 University of Twente, Netherlands
2 Aicas GmbH, Karlsruhe, Germany
CHART: An Approach for Non InvasiveGraph Transformation
CHART 2
Graphs
Structured graphical diagram:
nodes
attributes
directed edges
multiplicity, ordered, ….
Apr 18, 2012
attribute
Node Node
attribute
edge 1..*
CHART 3
Graph rules
Pair of graphs:
left-hand-side: matching
right-hand-side: updating
Apr 18, 2012
X
o
X
o
Xp
X
CHART 4
Graph rule application (1)
Apr 18, 2012
X
o
X
o
Xp
X
X
o
X
o
X
o
p
CHART 5
Graph rule application (2)
Apr 18, 2012
X
p X
X
o
X
X
o X
X
o
X
X
X p X
X
o
X X
o X
X
o
X
X
p p
p p
CHART 6
Overview
Idea: embed graph transformation in Java.
Our approach:
custom annotation language
custom transformation language (CHART)
custom compiler (RDT)
Demo: hashi puzzle.
User experiences.
Conclusions.
Apr 18, 2012
CHART 7
Observation
Run-time data of an object oriented program:
objects
fields:
references
basic data
Apr 18, 2012
data
Object Object
data
reference
CHART 8
Observation
Run-time data of an object oriented program forms a graph:
objects → nodes
fields:
references → edges
basic data → attributes
Apr 18, 2012
attribute
Node Node
attribute
edge
CHART 9
Idea
Use graph transformation to express manipulation of Java data.
Compile graph transformation to Java code.
Benefits:
Java: General purpose programming language.
GT: Special purpose transformation language.
Requirements:
Embed: arbitrarily mix Java code and GT code.
Non invasive: user code does not have to be modified.
Geared towards Java programmers: intended users.
Efficient: little or no performance loss compared to Java.
Apr 18, 2012
Approach
CHA
RTE
R
Trai
ning
10
Rule Driven Transformer
JavaProgram
GraphView
GraphRules
JavaRules RDT
annotate
compile
refer to
Extended Java Program
Start point: Java program with OO data.
Step 1: build graph view.
Step 2: write graph rules.
Step 3: compile rules into Java.
End point: extended Java program.
CHART 11
Step 1: build graph view
Purpose of graph view:
Select relevant data structures.
Provide additional meta information.
Custom annotation language.
How should the graph rules manipulate data?
Rely on user provided manipulation methods.
Nodes: create, delete, match, visit all.
Fields: add, remove, get one, set one, visit all, clear, replace, get
size, membership, get index.
Manipulate single elements only.
Implementation can choose collection type freely.
Apr 18, 2012
CHART 12
Example (annotated node)@Nodepublic class Author {
private final String name; public Author(String name) { this.name = name; }
@NodeCreate(inits = {“name”}) public static Author create(String name) { return new Author(name);
}
@AttributeGet public String getName() { return this.name; }}
Apr 18, 2012
CHART 13
Example (annotated edge, 1)@Nodepublic class Book extends Readable {
private final List<Author> writtenBy;
public List<Author> getWrittenBy() { return this.writtenBy; }}