deltaj – enhancing software product line development using ... · pdf fileplatzhalter...
TRANSCRIPT
Platzhalter für Bild, Bild auf Titelfolie hinter das Logo einsetzen
DeltaJ –Enhancing Software Product Line Development using Xtext
Sven Schuster – – May 20, 2015Institute of Software Engineering and Automotive Informatics, Prof. Dr.-Ing. Ina Schaefer
May 20, 2015 | Sven Schuster | DeltaJ | Slide 2
Software Variants and Product Families
Home
Office
Professional
Products Driver Software
CommonArtifacts
VariableArtifacts
+
May 20, 2015 | Sven Schuster | DeltaJ | Slide 3
Software Product Lines (SPLs)D
omai
nEn
gine
erin
gAp
plic
atio
nEn
gine
erin
g
Realization Artifacts
Generator Products/Variants
Feature Model
Configuration
May 20, 2015 | Sven Schuster | DeltaJ | Slide 4
Delta-Oriented Programming (DOP)
Modification operations1. Addition of new elements2. Modification of existing elements3. Removal of existing elements
Delta Modules Introducing Legacy Product Modify Legacy Product Disjoint Source Code fragments
Transformational Approach Efficiently implement SPLs Transform Legacy Product to specific variant Combine expressiveness & cohesion
LegacyProduct
RemoveInkJet
AddLaser
AddScanner
AddCopy
May 20, 2015 | Sven Schuster | DeltaJ | Slide 5
Delta-Oriented Programming (DOP)
Source Artifact
public class PrintController {void handleJob(Job j) {
j.print();}
}
Delta Module
delta DImageProcessor {modifies class PrintController {modifies void handleJob(Job j) {
preprocess(j);original(j);
}}
}
Target Artifact
public class PrintController {void handleJob(Job j) {
preprocess(j);j. print();
}}
+
JavaJava
DeltaJava
May 20, 2015 | Sven Schuster | DeltaJ | Slide 6
Delta-Oriented Programming (DOP)D
omai
nEn
gine
erin
gAp
plic
atio
nEn
gine
erin
g
Delta Modules
Generator Products/Variants
Feature Model
Configuration
mappingd1
d2d3
d4d5
m
n
May 20, 2015 | Sven Schuster | DeltaJ | Slide 7
• Ideas• Concrete SyntaxDeltaJ
• Challenges• SolutionsScoping
• Challenges• Thoughts
Type System
Agenda
May 20, 2015 | Sven Schuster | DeltaJ | Slide 8
DeltaJ
Idea Implement DOP for Java 1.5 Modification operations for everything
Modification Operations1. Package system (package org.pkg)2. API access (import org.pkg.Class)3. Type definitions (class, interface, enum, @interface)4. Inheritence model (class A implements C, D {...})5. Fields & Methods (int var = 0; public void operation() { ... })6. Modifiers (public, private, static, final, ...)7. Nested types (class A { class B {...} })
May 20, 2015 | Sven Schuster | DeltaJ | Slide 9
delta DLitAddPrint {adds {
public interface org.epl.Exp {void print();
}}adds {
package org.epl.op;import org.epl.Exp;public class Add implements Exp {
private Exp expr1, expr2;public Add(Exp a, Exp b) {
this.expr1 = a; this.expr2 = b;}@Overridespublic String print() {
return expr1.print() + " + "+ expr2.print();
}}
}}
DeltaJ – Concrete Syntax
Delta Module – Additions Delta Module – Modifications
delta DOptionalPrint {
modifies org.epl.op.Add {
modifies package com.epl.op;
modifies expr1 {public static}modifies print() {
String old = original(); System.out.println("(" + old + ")");
return old;
}
}
}
Delta Module – Removals
delta DremAdd {
removes org.epl.op.Add;
}
Add completeCompilationUnits
Modify Package
Modify Modifier
Call originalImplementation
May 20, 2015 | Sven Schuster | DeltaJ | Slide 10
DeltaJ – Application Rules
SPL Declaration
SPL EPL {Features = {Lit, Add, Neg, Print, Eval}Deltas = {DLitAddPrint, DNeg, DremAdd, DLitEval,
DAddEval, DNegEval, DNegPrint, DOptionalPrint}Constraints {
Lit & Print;}Partitions {
{DLitAddPrint} when (Lit & Print),{DNeg} when (Neg);{DremAdd} when (!Add);{DLitEval} when (Eval),{DAddEval} when (Add & Eval),{DNegEval} when (Neg & Eval),{DNegPrint} when (Neg), {DOptionalPrint} when (Add & Neg);
}Products {
generate Basic = {Lit, Print};Full = {Lit, Add, Neg, Print, Eval};
}}
Feature Model
Application Rules
Partial Order
Products
May 20, 2015 | Sven Schuster | DeltaJ | Slide 11
Implementation Challenges – Java Grammar
DeltaJ grammar DOP Modification operations Complete Java 1.5 syntax support Comparability of DeltaJ (DOP) to other approaches (FeatureHouse, Antenna, ...)
Xbase‘s XExpressions Local & global elements can be referenced
JvmTypes for references
DOP integrated with Java 1.5 Modular point of view Additional variability layer
Complete CompilationUnit (adds) Isolated Java member code (modifies)
in same file
May 20, 2015 | Sven Schuster | DeltaJ | Slide 12
Implementation Challenges – Scoping I
Declarationdelta DFoo {
adds {public class Foo {void foo() {
System.out.println(„foo“);}
}}
}
delta DBar {modifies Foo {
adds void bar() {foo();
}}
}
Modification
Inter-delta References Find the declaration and resolve reference Declaration may not be in adds unit
delta DQux {modifies Foo {
adds void qux() {bar();
}}
}
delta DQux {modifies Foo {
adds void qux() {bar();
}}
}
Further Modification
adds void bar() {
May 20, 2015 | Sven Schuster | DeltaJ | Slide 13
Implementation Challenges – Scoping II
Multiple declarations Where to scope?
?delta Dbar {
modifies Foo {adds void bar() {
foo();}
}}
Declarationdelta DFoo {
adds {public class Foo {void foo() {
System.out.println(„foo“);}
}}
}
void foo() {
delta Dbar {modifies Foo {
adds void bar() {foo();
}}
} delta DAlternativeFoo {adds {
public class Foo {void foo() { /* ... */ }
}}
}
Inter-delta Reference
Alternative Declaration
May 20, 2015 | Sven Schuster | DeltaJ | Slide 14
Implementation Challenges – Scoping III
Declarationdelta DFooBar {
adds {import java.util.List;import java.util.LinkedList;
public class Foo {List l = new LinkedList();
}}
adds {import java.util.List;import java.util.ArrayList;
public class Bar {List l = new ArrayList();
}}
}
Multiple XImportSections Multiple Java CompilationUnits in one file Adding Imports in modifies units
using XImportDeclaration
XImportSectionNamespaceScopeProvider scopes to first XImportSection
DeltaJXImportSectionNamespaceScopeProvider ?Import in Modifies Unitdelta DFoo {
modifies Foo {adds import java.util.Set;adds Set s;
}} XImportDeclaration
May 20, 2015 | Sven Schuster | DeltaJ | Slide 15
Implementation Solutions – Scoping
Problem I Resolve references to own classes/interfaces Resolve references to the Standard Library and other libraries
Solution Use JvmTypeReferences, XImportSection etc.
Problem II Resolve references to own classes/interfaces...
...that are not yet built... ...without knowing their exact configuration at compile-time
Resolve inter-delta references
Solution Overapproximate
Take every adds and modifies unit of every Delta into account Disregard removes operations Build JvmTypes for each unit
May 20, 2015 | Sven Schuster | DeltaJ | Slide 16
Implementation Solutions – Scoping
JvmModelInferrer Create JvmTypes of all adds and modifies units Only consider interfaces of types (no method bodies) Combine adds and modifies units contributing to the same CompilationUnit
Multiple Declarations? Unique reference cannot be resolved
with overapproximation Derive constraints from delta
application rules and feature model? Allow multi-target references?
DeltaJScopeProvider Resolves references Uses JvmTypes created in JvmModelInferrer
adds
modifies
modifies
May 20, 2015 | Sven Schuster | DeltaJ | Slide 17
Implementation Solutions – Scoping
JvmModelInferrer Create JvmTypes of all adds and modifies units Only consider interfaces of types (no method bodies) Combine adds and modifies units contributing to the same CompilationUnit
Multiple Declarations? Unique reference cannot be resolved
with overapproximation Derive constraints from delta
application rules and feature model? Allow multi-target references?
DeltaJScopeProvider Resolves references Uses JvmTypes created in JvmModelInferrer
adds
modifies
modifies
May 20, 2015 | Sven Schuster | DeltaJ | Slide 18
Implementation Challenges – Type System
Family-Based Type Checking For each modification/removal: Has the element been introduced?
Derive application constraint: D_mod(T) => D_add(T)
For each referenced member: Is it introduced and visible? Derive application constraint: D_ref(T) => D_add(T)
Is each member introduced more than once? Derive application constraint: AtMost1(..., D_add_i(m), ...)
Can the deltas be applied in the given application order? Application order constraint: Order(D_add(T), D_ref(T))
...
May 20, 2015 | Sven Schuster | DeltaJ | Slide 19
Implementation Challenges – Type System
/* ... */Constraints {
Lit & Print;}Partitions {
{DLitAddPrint} when (Lit & Print),{DNeg} when (Neg);{DremAdd} when (!Add);{DLitEval} when (Eval),{DAddEval} when (Add & Eval),{DNegEval} when (Neg & Eval),{DNegPrint} when (Neg), {DOptionalPrint} when (Add & Neg);
}/* ... */
SPL DeclarationFamily-Based Type Checking Check constraints on Delta application
rules, application order and feature model
D_mod(org.epl.op.Add) => D_add(org.epl.op.Add)
DOptionalPrint => DLitAddPrint
Order(DLitAddPrint, DOptionalPrint)
May 20, 2015 | Sven Schuster | DeltaJ | Slide 20
Evaluation – Case Study Implementation
Current Status Delta-oriented Text Editor
11 Features 11 Deltas 1373 SLOC 128 Variants
Only tiny case study
Future Plans Refactor „big“ Open Source Software to
DeltaJ Product Line BerkeleyDB JHotDraw
Usability Study
May 20, 2015 | Sven Schuster | DeltaJ | Slide 21
Conclusion
http://www.tu-bs.de/isf/team/schuster
More Informationhttp://www.tu-bs.de/isf/research/deltas/
What‘s left to do? Get rid of overapproximate scoping? How to handle multiple declarations? Evaluate the correctness
Thank you!
DeltaJ 1.5 Full Java 1.5 Syntax Support Complete set of Modification Operations Overapproximate Scoping Concept for Type System for DeltaJ