78
Budapest University of Technology and Economics Department of Measurement and Information Systems A Bridge over Troubled Water: Synergies between Model Transformation and Software Maintenance Techniques Dániel Varró Budapest University of Technology and Economics CSMR 2012 Szeged, Hungary, March 29th, 2012

A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Embed Size (px)

DESCRIPTION

Invited talk at CSMR 2012, 16th European Conference on Software Maintenance and Reengineering

Citation preview

Page 1: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Budapest University of Technology and Economics Department of Measurement and Information Systems

A Bridge over Troubled Water: Synergies between

Model Transformation and Software Maintenance Techniques

Dániel Varró

Budapest University of Technology and Economics

CSMR 2012 Szeged, Hungary, March 29th, 2012

Page 2: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Song writing methods of Simon and Garfunkel

Page 3: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Paul Simon’s technique #1

3

1. Create music first

Bridge Over Troubled Water When you're weary Feeling small When tears are in your eyes I will dry them all I'm on your side When times get rough And friends just can't be found Like a bridge over troubled water I will lay me down Like a bridge over troubled water I will lay me down

2. Write lyrics accordingly

Page 4: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Paul Simon’s technique #2

4

2. Compose music accordingly

The Boxer I am just a poor boy Though my story's seldom told I have squandered my resistance For a pocket full of mumbles such are promises All lies and jests Still a man hears what he wants to hear And disregards the rest When I left my home and my family I was no more than a boy In the company of strangers In the quiet of the railway station running scared Laying low, seeking out the poorer quarters Where the ragged people go Looking for the places only they would know

1. Write lyrics first

Page 5: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

A Combined Technique…

5

The Side of a Hill (P. Simon) On the side of a hill, a little cloud weeps And waters the grave with its silent tears While a soldier cleans and polishes a gun

Canticle (rearranged by A. Garfunkel) On the side of a hill a sprinkling of leaves Washes the grave with silvery tears A soldier cleans and polishes a gun

Scarborough Fair (Folk Song) Tell her to find me an acre of land, Parsley, sage, rosemary and thyme; Between the salt water and the sea strand, Then she'll be a true love of mine.

Page 6: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Naming These Techniques…

6 2. Compose music accordingly

The BoxerI am just a poor boy Though my story's seldom told I have squandered my resistance For a pocket full of mumbles such are promises All lies and jests Still a man hears what he wants to hear And disregards the rest When I left my home and my family I was no more than a boy In the company of strangers In the quiet of the railway station running scared Laying low, seeking out the poorer quarters Where the ragged people go Looking for the places only they would know

1. Write lyrics first

Music Driven Song Development (MDSD)

Lyrics Driven Song Development

1. Create music first

Bridge Over Troubled Water

When you're weary Feeling small When tears are in your eyes I will dry them all

I'm on your side When times get rough And friends just can't be found Like a bridge over troubled water I will lay me down Like a bridge over troubled water I will lay me down

2. Write lyrics accordingly

Page 7: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Applying the Principle to Software Systems

7

Music

Bridge Over Troubled Water When you're weary Feeling small When tears are in your eyes I will dry them all I'm on your side When times get rough And friends just can't be found Like a bridge over troubled water I will lay me down Like a bridge over troubled water I will lay me down

Lyrics

Model Code

Page 8: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Some Well-known Transformations

8

Model Code

Code generation

Refactoring Model

Refactoring

Re-engineering

Program comprehension Query

Model Query

Generative programming

Page 9: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

A Classification of Transformations

9

Model Code M2T: Model-to-Text

T2M: Text-to-Model

M2M: Model-to-Model T2T: Text-to-Text

Model Transformations: Topic of this talk

Page 10: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Model-Driven Software Development

10

Model Code M2T: Model-to-Text

M2M: Model-to-Model

Conferences: MODELS, ECMFA, ICMT

Page 11: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Software Maintenance and Re-engineering

11

Model Code

T2M: Text-to-Model

T2T: Text-to-Text

Conferences: CSMR, ICSM …

Page 12: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Objectives: Build More Bridges for Roundtrips

12

Model Code M2T: Model-to-Text

T2M: Text-to-Model

M2M: Model-to-Model T2T: Text-to-Text

Page 13: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Talk Overview

13

Overview & Applications of MT •Basics •Applications from own practice

A tool (MTSMR) • to build your SMR tool • increm. model queries

Targets (SMRMT)

• future research • collaboration

Page 14: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Model Transformations in Model Driven Software Development

Page 15: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Development Process for Critical Systems Unique Development Process

(Traditional V-Model)

Critical Systems Design

requires a certification process

to develop justified evidence

that the system is free of flaws

Software Tool Qualification

obtain certification credit

for a software tool

used in critical system design

Qualified Tool Certified Output

DO-178B IEC 61508

Innovative Tool Better System

Page 16: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Model-Driven Engineering of Critical Systems

Traditional V-Model Model-Driven Engineering

Main ideas of MDE • early validation of system models • automatic source code generation quality++ tools ++ development cost--

• DO-178B/C: Software Considerations in Airborne Systems and Equipment Certification (RTCA, EUROCAE) • Steven P. Miller: Certification Issues in Model Based Development (Rockwell Collins)

Page 17: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Models and Transformations in Critical Systems

System Design Model

Architecture Design Model

Component Design Model

Refine

Refine

Model Transformations • systematic foundation of knowledge transfer: theoretical resultstools • bridge / integrate existing languages&tools

Design + V&V Artifacts (Source code, Glue code, Config. Tables, Test Cases, Monitors, Fault Trees, etc.)

Code Generation

Test Generation

Ve

rtical Mo

de

l Transfo

rmatio

ns

Component V&V Model

Architecture V&V Model

System V&V Model

Model generation

Back-Annotation

Model generation

Back-Annotation

Model generation

Back-Annotation

Use

Use

Horizontal Model Transformations

Formal methods

Formal methods

Design rules

Design rules

Design rules

Related projects • CESAR, SAVI, … • HIDE, DECOS, DIANA, MOGENTES, CERTIMOT, GENESYS, SENSORIA

Page 18: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Modeling Languages and Model Transformations

Page 19: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Overview: Foundations of Model Transformations

System Design Model

Architecture Design Model

Component Design Model

Refine

Refine

Design + V&V Artifacts (Source code, Glue code,

Config. Tables, Test Cases, Monitors, Fault Trees, etc.)

Code Generation

Test Generation

Ve

rtical Mo

de

l Transfo

rmatio

ns

Component V&V

Model

Architecture V&V Model

System V&V Model

Model generation

Back-Annotation

Model generation

Back-Annotation

Model generation

Back-Annotation

Use

Use

Horizontal Model Transformations

Formal methods

Formal methods

Design rules

Design rules

Design rules

Foundations of model transformations

Page 20: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Domain Specific Modeling Languages Concrete syntax

(Graphical/Textual)

Code generation

View

Well-formedness constraints

Behavioural semantics, Simulation

Abstract syntax (Metamodel)

Mapping

Source Code (Documentation,

Configuration file)

Concrete syntax: • How the designer sees it • Graphical/textual/both

Domain-Specific Modeling Languages (DSML): • Foundations of many modern tool (design, analysis, V&V) • Domains: avionics, automotive, business modeling

Page 21: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Domain Specific Modeling Languages Concrete syntax

(Graphical/Textual)

Code generation

View

Well-formedness constraints

Behavioural semantics, Simulation

Abstract syntax (Metamodel)

Mapping

Source Code (Documentation,

Configuration file)

Abstract syntax: • Internal graph representation • Defined by a metamodel

Page 22: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Domain Specific Modeling Languages Concrete syntax

(Graphical/Textual)

Code generation

View

Well-formedness constraints

Behavioural semantics, Simulation

Abstract syntax (Metamodel)

Mapping

Source Code (Documentation,

Configuration file)

Well-formedness constraints: • REQs for valid static models • Captured declaratively (OCL)

Page 23: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Domain Specific Modeling Languages Concrete syntax

(Graphical/Textual)

Code generation

View

Well-formedness constraints

Behavioural semantics, Simulation

Abstract syntax (Metamodel)

Mapping

Source Code (Documentation,

Configuration file)

Behavioural Semantics: • For dynamic MLs only (statecharts, business processes) • Enables model simulation/execution

Page 24: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Domain Specific Modeling Languages Concrete syntax

(Graphical/Textual)

Code generation

View

Well-formedness constraints

Behavioural semantics, Simulation

Abstract syntax (Metamodel)

Mapping

Source Code (Documentation,

Configuration file)

View/Compile/Map: • View / code generation • Model transformation exercise

Page 25: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Model Transformation Overview: Metamodels

Modeling tool

Source model

Source metamodel

Target model

Target metamodel

MT rule

Metamodel: Precise spec of a modeling language

Page 26: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Modeling tool

Model Transformation Overview: Models

Source model

Source metamodel

Target model

Target metamodel

MT rule

Model: Description of a concrete system

t1:Transition

t2:Transition

p1:Place p2:Place

a1:PTArc a2:TPArc

a4:TPArc a3:PTArc

tk:Token

Eclipse Modeling Framework (EMF): • De facto modeling standard for Eclipse based modeling tools • Design metamodel auto-generate

interface, implementation, tree editor… • Examples: UML, AADL, SysML, BPMN, AUTOSAR >30 in a single IBM tool

Page 27: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Modeling tool

Model Transformation Overview: Rules

Source model

Source metamodel

Target model

Target metamodel

MT rule

Model Transformation: How to generate a target equivalent of an arbitrary source model

LHS RHS

Place

Token

Tran. Place

a1:inarc a2:outarc

Place

Token

Tran. Plan

a1:inarc a2:outarc

ttn1:tokens tkn2:tokens

Page 28: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Model Transformation Overview: Rule Execution

Eclipse Framework

Model Transformation Tool

Modeling tool

Source model

Source metamodel

Target model

Target metamodel

MT rule

MT engine

Transformation engine: Support for querying and manipulating large models

VIATRA2: http://www.eclipse.org/gmt/VIATRA2/

ATL

QVT

Page 29: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Model Transformation by Graph Transfromation

Eclipse Framework

Model Transformation Tool

Modeling tool

Source model

Source metamodel

Target model

Target metamodel

MT rule

MT engine

query/match update

LHS RHS

Place

Token

Tran. Place

a1:inarc a2:outarc

Place

Token

Tran. Plan

a1:inarc a2:outarc

ttn1:tokens tkn2:tokens

Page 30: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

3rd Party Tool

Native source model

Native target model

Overview of Model Transformations Eclipse Framework

Model Transformation Tool

Modeling tool

Source model

Source metamodel

Target model

Target metamodel

MT rule

MT engine

Native source models: • EMF • XML documents • Databases • Domain-specific models • UML

Native target models: • EMF • App source code • XML deployment descript. • Databases • Analysis tools

Page 31: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

3rd Party Tool

Native source model

Native target model

Standalone Model Transformations Plugins Eclipse Framework

Model Transformation Tool

Modeling tool

Source model

Source metamodel

Target model

Target metamodel

MT rule

MT engine

Native MT plugin

Code generator Standalone transformation: Independent of transformation development environment

D. Varró, A. Pataricza: Generic and Meta-Transformations for Model Transformation Engineering . UML 2004

Page 32: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Incremental Model Queries

By EMF-IncQuery

Page 33: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Overview: Early Validation of Design Rules

System Design Model

Architecture Design Model

Component Design Model

Refine

Refine

Design + V&V Artifacts (Source code, Glue code,

Config. Tables, Test Cases, Monitors, Fault Trees, etc.)

Code Generation

Test Generation

Vertical M

od

el Transfo

rmatio

ns

Component V&V

Model

Architecture V&V Model

System V&V Model

Model generation

Back-Annotation

Model generation

Back-Annotation

Model generation

Back-Annotation

Use

Use

Horizontal Model Transformations

Formal methods

Formal methods

Design rules

Design rules

Design rules

Validation of design rules by incremental model queries

Page 34: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Challenge: Early validation of design rules

SystemSignalGroup design rule (from AUTOSAR)

o A SystemSignal and its group must be in the same IPdu

o Challenge: find violations quickly in large models

o New difficulties

• reverse navigation

• complex manual solution

AUTOSAR: • standardized SW architecture of the automotive industry • now supported by modern modeling tools Design Rule/Well-formedness constraint: • each valid car architecture needs to respect • designers are immediately notified if violated Challenge: • >500 design rules in AUTOSAR tools • >1 million elements in AUTOSAR models • models constantly evolve by designers

Page 35: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Example: SystemSignalGroup design rule (from AUTOSAR)

A SystemSignal and its signal group must be in the same IPDU (Protocol Data Unit)

Our approach

Capture design rules as model queries

Incremental re-validation Others approaches: X. Blanc,

A. Egyed, T. Mens,OCL, …

Capturing design rules as model queries

ModelQuery(A,B): • tuples of model elements A, B • satisfying the query condition • enumerate 1 / all instances • A,B can be input or output

Page 36: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Graph Patterns as Query Language Graph patterns as

declarative query language o Attribute constraints

o Local + global queries

o Compositionality + Reusabilility

o „Arbitrary” Recursion, Negation, Transitive Closure

o Syntax: DATALOG style

pattern mappedSignal(S,M,P) = {

SignalIPdu(P); signalToPduMapping(R3,P,M);

ISignalToIPduMapping(M); signal(R1,M,S); ISignal(S);

}

pattern systemSignal(S,SS) = { ISignal(S); systemSignal(R2,S,SS); SystemSignal(SS);

}

pattern systemSignalGroup(P) = { find mappedSignal(S_Child,M_Child,P);

find systemSignal(S_Child,SS_Child); systemSignal(R7,SS_Parent,SS_Child); find systemSignal(S_Parent,SS_Parent); neg find mappedSignal(S_Child,M_Child,P);

}

Page 37: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Incremental Evaluation of Graph Queries Graph patterns as

declarative query language o Attribute constraints

o Local + global queries

o Compositionality + Reusabilility

o „Arbitrary” Recursion, Negation, Transitive Closure

o Syntax: DATALOG style

pattern mappedSignal(S,M,P) = {

SignalIPdu(P); signalToPduMapping(R3,P,M);

ISignalToIPduMapping(M); signal(R1,M,S); ISignal(S);

}

pattern systemSignal(S,SS) = { ISignal(S); systemSignal(R2,S,SS); SystemSignal(SS);

}

pattern systemSignalGroup(P) = { find mappedSignal(S_Child,M_Child,P);

find systemSignal(S_Child,SS_Child); systemSignal(R7,SS_Parent,SS_Child); find systemSignal(S_Parent,SS_Parent); neg find mappedSignal(S_Child,M_Child,P);

}

Evaluation: incremental cache of matches (RETE) • Cheap maintenance of cache (only memory overhead) • Notify about relevant changes • Enable reactions to complex structural events

G. Bergmann et al.: Incremental evaluation of model queries over EMF models. MODELS 2010.

Page 38: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Scalability of EMF-IncQuery

Memory consumption: • < 50 MB for model size

below 50 000 elements • < 1GB for largest models (grows linearly)

Context of experiments: • Generated AUTOSAR models • > 1,5 million model elements • #violations << model size

G. Bergmann et al.: Incremental evaluation of model queries over EMF models. MODELS 2010.

EMF-IncQuery: available from http://viatra.inf.mit.bme.hu/incquery

Time of incremental revalidation: • < 10 ms • Depends on size of the change • Depends on number of violations but • Independent from model sizes

Measured scenarios: • Read and first check • Change and revalidate

Page 39: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Cross technology benchmarking for on-the-fly model validation

39

Page 40: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

What technology to use for a model validation tool?

Eclipse Modeling

• EMF (&variants, CDO, …)

• Proven EMF tools: Plain Java queries, OCL (&variants), EMF Query (1-2)

• New/experimental technologies: EMF-IncQuery, JBoss Drools, …

Triple stores / graph databases

• OWL/RDF, SPARQL

• RacerPro, Pellet, Sesame, Jena, OpenVirtuoso, Allegro, StarDog

• But…

• Huge, distributed knowledge bases

• Frequently based upon Relational DB

• Optimized SPARQL engines

• Expensive commercial tools

Future plans (not covered yet) • Non-EMF modeling frameworks • Plain XML/Xpath • OO DB • K-V (NoSQL), …

Page 41: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Evaluation Results

Batch validation (Read + 1st query)

• Top: Eclipse OCL,followed by EMF-IncQuery

• Dominating: Read time

• SPARQL tools: 1-2 orders of magniture slower than top EMF tools

On-the-fly re-validation (Update + query)

• Top: Incremental EMF engines

• 5-10x faster than OCL

• EMF-IncQuery frequently outperforms JBoss Drools

• Response time: below 100ms for up to 1.5M elements

• Memory: ~1 GB

41

Page 42: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

EMF-IncQuery for Software Maintenance

Existing program query tools

• JQuery, CodeQuest, PQL, SOUL, JQL, ASTLog

• Incremental solutions: Willis et al. (JQL), Rothamel&Liu08, …

• coding conventions, metrics, refactoring opportunities, design patterns, run-time errors

Ongoing application of EMF-IncQuery

• Interconnection of software module

• 4 million model elements (classes + packages)

• Much larger than Eclipse JDT could handle

42

Page 43: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Incremental Model Transformations

Page 44: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Overview: Incremental Model Synchronization

System Design Model

Architecture Design Model

Component Design Model

Refine

Refine

Design + V&V Artifacts (Source code, Glue code,

Config. Tables, Test Cases, Monitors, Fault Trees, etc.)

Vertical M

od

el Transfo

rmatio

ns

Code Generation

Test Generation

Component V&V

Model

Architecture V&V Model

System V&V Model

Back-Annotation

Back-Annotation

Back-Annotation

Use

Use

Horizontal Model Transformations

Model generation

Model generation

Model generation

Formal methods

Formal methods

Design rules

Design rules

Design rules

Incremental model synchronization by change-driven transformations

Page 45: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Incremental Forward Transformation

MSRC MTRG TRACE

M’SRC M’TRG TRACE’

1. First transformation

2. Source model changes

3. Apply changes to target model

Practical application scenarios: • Incremental model synchronization • Tool integration

Solutions: • Bidirectional transformations • Change-driven transformations

Page 46: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Incremental Backward Transformation

MSRC MTRG TRACE

M’SRC TRACE’ M’TRG

1. First transformation

2. Target model changes

3. Apply changes to source model

Challenge: SRCTRG specified TRGSRC inferred

Recent Approaches: A. Schürr, P. Stevens, N. Foster, T. Hettel, Cicchetti&Pierantonio, Czarnecki&Diskin

Page 47: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Incremental Deployment of Business Processes

47

Executing business process • XML document (jPDL / JBoss) • Deployed on a remote server

Business Process Model • EMF model (BPMN) • Available in Eclipse IDE

Goal: • Avoid full redeployment of XML upon changes in BPMN model • Apply model changes asynchronously (any time later) • Send changes via a XML-DOM API

NewAct <action name="NewAct">

Page 48: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Ráth, Varró, Varró : Change Driven Transformations- MODELS 2009

Change Driven Model Transformations

Change ModelTRG

Change Driven Model Transformations

MSRC MTRG TRACE

M’SRC M’TRG TRACE’

Change Driven Transformation • Input: consumes change model • Output: produces change model

Apply Target Change Model • via an API with little trace info • target model is not materialized!

Change ModelSRC

Page 49: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Design Space Exploration

Hegedüs et al.: A Model Driven Framework for Guided Design Space Exploration ASE 2011

Hegedüs et al.: Quick fix generation for DSMLs. VL/HCC 2011

Page 50: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Model-Driven Guided Design Space Exploration

Test Generation

Vertical M

od

el Transfo

rmatio

ns

System Design Model

Architecture Design Model

Component Design Model

Refine

Refine

Design + V&V Artifacts (Source code, Glue code,

Config. Tables, Test Cases, Monitors, Fault Trees, etc.)

Code Generation

Component V&V

Model

Architecture V&V Model

System V&V Model

Model generation

Back-Annotation

Model generation

Back-Annotation

Model generation

Back-Annotation

Use

Use

Horizontal Model Transformations

Formal methods

Formal methods

Design rules

Design rules

Design rules

Model-driven guided design space exploration • Quick fixes for DSMLs • Design of ARINC653 configs

Page 51: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Fixing errors in modern IDEs

51

Visual Studio Smart Compile Auto Correction

Netbeans Editor Hints Eclipse Quick Fix

Page 52: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Our Context: Validation of BPMN processes

52

How to fix these inconsistencies?

Standard Eclipse BPMN tool

Page 53: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Quick fix generation for BPMN editors

53

Page 54: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Design Space Exploration

54

Design Space Exploration

Design Alternative 1

Design Alternative 2

Design Alternative 3

Design Alternative 4

Goals

Global Constraints

Operations

Initial Design

Special state space exploration • potentially infinite state space • „dense” solution space

Page 55: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Model Driven Guided Design Space Exploration

55

Design Space Exploration

Seq of Transf. Rules 1

Seq of Transf. Rules 2

Seq of Transf. Rules 3

Seq of Transf. Rules 4

Model queries as Goals

Model queries as Constraints

Transf. Rules as Operations

Initial Model

Guidance for exploration: Hints • designer / end user • formal analysis

Modified model

Operation

Initial model

Solution model

Constraints violated

Goals satisfied

Page 56: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Result: Quick fix generation for BPMN editors

56

List of fixes Sequence of edit operations

Context

Page 57: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Back-annotation of Execution Traces for Model Analysis

Page 58: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Overview: Back-Annotation of Execution Traces

System Design Model

Architecture Design Model

Component Design Model

Refine

Refine

Design + V&V Artifacts (Source code, Glue code,

Config. Tables, Test Cases, Monitors, Fault Trees, etc.)

Code Generation

Test Generation

Vertical M

od

el Transfo

rmatio

ns

Component V&V

Model

Architecture V&V Model

System V&V Model

Model generation

Back-Annotation

Model generation

Back-Annotation

Model generation

Back-Annotation

Use

Use

Horizontal Model Transformations

Formal methods

Formal methods

Design rules

Design rules

Design rules

Back-annotation of execution traces

Page 59: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Model Analysis: Motivation for BPEL

Requirement: Every received request must result in a reply! Will the business process assure this?

Receive request

Calculate Rating

Send offer

Accept?

Receive answer

Send reply

Send rejection

Receive update request

Update?

Rollback changes

Throw Error

Event: Cancel

Yes No

Yes No

Page 60: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Motivating scenario (cont.)

Requirement: Every received request must result in a reply!

Receive request

Calculate Rating

Send offer

Accept?

Receive answer

Send reply

Send rejection

Receive update request

Update?

Rollback changes

Throw Error

Event: Cancel

Yes No

Yes No

Page 61: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Motivating scenario (cont.)

Requirement: Every received request must result in a reply!

Receive request

Calculate Rating

Send offer

Accept?

Receive answer

Send reply

Send rejection

Receive update request

Update?

Rollback changes

Throw Error

Event: Cancel

Yes No

Yes No

Returns with a web-service error

Not executed = No reply

Page 62: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

High-level

System Model

Model Based Analysis System design

Mathematical

model

Model

generation

Mathematical analysis

List of

inconsistencies Analysis (e.g model checker)

Fix problem Receive request

Calculate Rating

Send offer

Accept?

Receive answer

Send reply

Send rejection

Receiveupdate request

Update?YesNo

Yes No

Page 63: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Counter-example / Execution traces

Page 64: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Back-Annotation of Counter Example Traces

High-level

System Model Mathematical

model

Model

generation

Back-annotation

of target trace Analysis

(e.g model checker)

Replay of

source trace

Receive request

Calculate Rating

Send offer

Accept?

Receive answer

Send reply

Send rejection

Receiveupdate request

Update?YesNo

Yes No

Fire Transition

Select Transition

Fire Transition

Select Transition

Add Tokens

Delete Tokens

BPEL Activity Executed

BPEL Activity Runs

BPEL Activity Startable

MPN MBPEL

MPN’

CHMPN

MBPEL’

CHMBPEL

IF

map

TR

TR

Page 65: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Replay Traces in BPEL Simulator

High-level

System Model Mathematical

model

Model

generation

Replay of

source trace

Analysis (e.g model checker)

Back-annotation

of target trace

Receive request

Calculate Rating

Send offer

Accept?

Receive answer

Send reply

Send rejection

Receiveupdate request

Update?YesNo

Yes No

Extended BPEL Simulator: • Current state: coloured • Intuitive navigation along the trace

Page 66: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Software Maintenance Techniques for Model Transformations

Page 67: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Reengineering and Model Transformations

Graph eXchange Language (GXL)

• R. Holt, A. Schürr, S.E. Sim, A. Winter (2000)

• Used by >30 tools (from both communities)

TTC 2011: Transformation Tool Contest

• Case for program understanding / reengineering (T. Horn)

• Solved by 7 MT tools

67

Source code

parse

Model query

Page 68: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Design Patterns and Metrics vs. MT

Design Patterns by MT

• Design pattern / smell captured as a query

• Modifications as MT rules

• Extensive literature

Design patterns for MTs

• Good design practices for MT

• Karsai et al, Iacob et. al, Lano et al.,

Metrics for MT

• Quality assessment for MT

• van Amstel et al., Vignana, Saeki, Kapova et al.,

• Only since 2009/2010

68

Model

Design Pattern

query

Model

Metrics Definition

query

MT

measure

Page 69: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Refactoring vs. Model Transformations

MT for refactoring

o T. Mens, G. Taentzer,

o L. Vidács, R. Ferenc, M. Gogolla

o Van Eetvelde, Janssens

o J. Grey, …

o EMF-Refactor

Refactoring of MT

o Ehrig et al. 2009

69

Source Code 1

Model 1

MT

Model 2

Source Code 2

MT1

as model

MT2

as model refactor

Page 70: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Migration / Evolution

Model migration o Metamodel

changes to new version Migrate model instances

o Tools: COPE/Edapt, EPSILON FLOCK, (Herrmannsdörfer, Kolovos, Paige, Levendovszky et al.)

MT migration o Mendez et al. o Roser&Bauer

70

Model

Metamodel v1

change Metamodel

v2

Model

update

MT

Metamodel v1

change Metamodel

v2

MT

update

Page 71: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Slicing of Model Transformations

Problem:

o Erroneous MT invalidates formal analysis results

Motivation:

o Debugging of MTs

o Focus on specific executions

Idea Apply program slicing

o Identify parts of a MT program

o Causally dependent on a selected statement

71

Transformation Slice

Model Slice

Model Transformation Slicing

Transformation Program

Models

Z. Ujhelyi, A. Horvath, D. Varró: Dynamic backward Slicing of MT programs. ICST 2012

Page 72: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Conclusions

Page 73: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Foundations of Model Transformations

System Design Model

Architecture Design Model

Component Design Model

Refine

Refine

Design + V&V Artifacts (Source code, Glue code,

Config. Tables, Test Cases, Monitors, Fault Trees, etc.)

Code Generation

Test Generation

Ve

rtical Mo

de

l Transfo

rmatio

ns

Component V&V

Model

Architecture V&V Model

System V&V Model

Model generation

Back-Annotation

Model generation

Back-Annotation

Model generation

Back-Annotation

Use

Use

Horizontal Model Transformations

Formal methods

Formal methods

Design rules

Design rules

Design rules

Foundations: • MDSD= early validation + auto-generation of sources • DSMLs drive modern tools • MTs drive bridges (integration) • MT rule = Query + Manipulate

Page 74: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Incremental Validation of Design Rules by Model Queries

System Design Model

Architecture Design Model

Component Design Model

Refine

Refine

Design + V&V Artifacts (Source code, Glue code,

Config. Tables, Test Cases, Monitors, Fault Trees, etc.)

Code Generation

Test Generation

Vertical M

od

el Transfo

rmatio

ns

Component V&V

Model

Architecture V&V Model

System V&V Model

Model generation

Back-Annotation

Model generation

Back-Annotation

Model generation

Back-Annotation

Use

Use

Horizontal Model Transformations

Formal methods

Formal methods

Design rules

Design rules

Design rules

EMF-IncQuery • Declarative graph query language • Incremental caches of result set • Scalable performance:>1 M elems

Page 75: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Incremental Model Synchronization by Change Driven MT

System Design Model

Architecture Design Model

Component Design Model

Refine

Refine

Design + V&V Artifacts (Source code, Glue code,

Config. Tables, Test Cases, Monitors, Fault Trees, etc.)

Vertical M

od

el Transfo

rmatio

ns

Code Generation

Test Generation

Component V&V

Model

Architecture V&V Model

System V&V Model

Back-Annotation

Back-Annotation

Back-Annotation

Use

Use

Horizontal Model Transformations

Model generation

Model generation

Model generation

Formal methods

Formal methods

Design rules

Design rules

Design rules

Change driven transfomations (CDT) • Changes stored as change models • CDT: Source change Target change • Non-materialized target models (API)

Page 76: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Model-Driven Guided Design Space Exploration

Test Generation

Vertical M

od

el Transfo

rmatio

ns

System Design Model

Architecture Design Model

Component Design Model

Refine

Refine

Design + V&V Artifacts (Source code, Glue code,

Config. Tables, Test Cases, Monitors, Fault Trees, etc.)

Code Generation

Component V&V

Model

Architecture V&V Model

System V&V Model

Model generation

Back-Annotation

Model generation

Back-Annotation

Model generation

Back-Annotation

Use

Use

Horizontal Model Transformations

Formal methods

Formal methods

Design rules

Design rules

Design rules

Guided DSE (є Search Based SE) • Potentially infinite search space • Frequent solutions • Hints to guide exploration

Page 77: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Back-Annotation of Execution Traces

System Design Model

Architecture Design Model

Component Design Model

Refine

Refine

Design + V&V Artifacts (Source code, Glue code,

Config. Tables, Test Cases, Monitors, Fault Trees, etc.)

Code Generation

Test Generation

Vertical M

od

el Transfo

rmatio

ns

Component V&V

Model

Architecture V&V Model

System V&V Model

Model generation

Back-Annotation

Model generation

Back-Annotation

Model generation

Back-Annotation

Use

Use

Horizontal Model Transformations

Formal methods

Formal methods

Design rules

Design rules

Design rules

Back-annotation • Goal: Hidden formal methods • TRG execution traces SRC execution traces • Demonstrate / Replay problem in SRC (engineering) model

Page 78: A Bridge over Troubled Water: Synergies between Model Transformations and Software Maintenance Techniques

Future Research Challenges

Metrics for MT

Slicing of MT

Migration of MT

Design patterns for MT

Refactoring of MT

Many thanks to

Contributors: G. Bergmann, L. Gönczy Á. Hegedüs, Á. Horváth, B. Izsó, A. Pataricza, I. Ráth, Z. Ujhelyi, G. Varró and many more

Thanks for your kind attention!

78