SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
A recommender system for 
generalizing and refining 
code templates 
Towards 
Coen De Roover, Tim Molderez
User-specified templates are ubiquitous 
code transformation 
code generation 
code search
Life without templates? 
manual implementations 
Imperative Program Transformation by Rewriting It says that an assignment x := v (where v is a variable) can x := c if the “last assignment” to v was v := c (where c is a constant). condition formalises the notion of “last assignment”, and will be the paper: 
tools taking exotic specifications 
n : (x := v) =⇒ x := c 
if 
n ⊢ A△(¬def(v) U def(v) ∧ stmt(v := c)) 
conlit(c)
But specifying templates is still hard… 
code template 
source code + meta-variables + matching directives 
often requires multiple iterations 
no required matches are missed generalization 
no unwanted matches 
refinement 
no support for editing process 
no disciplined methods for generalizing/refining templates 
no automated support in the form of recommender system
I’m a “structural search and replace” on steroids 
1/ advanced code templates in Ekeko/X 
2/ formal operators for template mutation 
3/ genetic search for mutation recommendations
1/ advanced code templates in Ekeko/X 
2/ formal operators for template mutation 
3/ genetic search for mutation recommendations 
template 
matches
1/ advanced code templates in Ekeko/X 
2/ formal operators for template mutation 
3/ genetic search for mutation recommendations 
template 
matches
1/ advanced code templates in Ekeko/X 
2/ formal operators for template mutation 
3/ genetic search for mutation recommendations 
template 
matches 
[<component>]@[<directive>]
[<component>]@[<directive>] 
constraining syntax, structure, 
data flow, control flow of matches 
match any match is in source code, 
with matching type and properties 
orsimple qualified name match is any name resolving to name in template 
(equals ?var) any exposes match 
child, child+, child* any match is corresponding child of parent match, nested 
within that child (+), or either (*) 
match|set list match has at least given elements, in any order 
match|regexp list match has elements described by regexp 
(type ?type) 
type/variable 
declaration/reference 
expression 
match resolves to, is of, or declares the type of its 
argument 
(subtype ?type), 
(subtype+ ?type), 
(subtype* /type) 
type/variable 
declaration/reference 
match resolves to a (transitive +, reflexive *) subtype 
of the given argument 
(refers-to ?var) expression match lexically refers to local, parameter or field 
denoted by its argument 
(invokes ?method) invocation expression match invokes given argument 
grouping of templates 
[public void acceptVisitor(ComponentVisitor v)…]@[(equals ?method)] 
[….acceptVisitor(…)]@[(invokes ?method)]
1/ advanced code templates in Ekeko/X 
2/ formal operators for template mutation 
3/ genetic search for mutation recommendations 
? ? 
?
1/ advanced code templates in Ekeko/X 
2/ formal operators for template mutation 
3/ genetic search for mutation recommendations 
introduce-variable return age; return ?v; 
atomic 
mutation 
generalize-aliases 
composite 
mutation 
public class Book { 
private Integer count; 
public Integer getCount() { 
return count; 
} 
} 
public class Book { 
private Integer ?v1; 
public Integer getCount() { 
return [?v2]@[(refers-to ?v1)]; 
} 
}
1/ advanced code templates in Ekeko/X 
2/ formal operators for template mutation 
3/ genetic search for mutation recommendations 
(Operator. 
"remove-node" 
operators/remove-node 
:destructive 
"Remove from template." 
opscope-subject 
applicability|deleteable 
"Removes its selection from the template." 
[]) 
(Operator. 
constraints on their subject 
"add-directive-invokes" 
operators/add-directive-invokes 
:refinement 
"Add directive invokes." 
opscope-subject 
applicability|methodinvocation 
"Requires matches to invoke the binding for the meta-variable." 
[(make-operand "Meta-variable (e.g., ?v)" opscope-variable validity|variable)]) 
constraints on their operands 
constraints enable checking 
applicability of operator, validity of its operands 
+ generating possible values!
1/ advanced code templates in Ekeko/X 
2/ formal operators for template mutation 
3/ genetic search for mutation recommendations 
given enumeration of desired matches 
populate determine fitness 
best 
individual good 
enough? 
select parents crossover 
& mutation 
yay!
1/ advanced code templates in Ekeko/X 
2/ formal operators for template mutation 
3/ genetic search for mutation recommendations 
populate 
individual = group of templates 
- copies of existing group (from editor state) 
- one template group per row, 
consisting of a template per column in desired matches (from scratch)
1/ advanced code templates in Ekeko/X 
2/ formal operators for template mutation 
3/ genetic search for mutation recommendations 
determine fitness concurrently! 
a) match each template group in population against program 
b) determine precision and recall w.r.t. desired matches 
c) penalize excess use of directives (KISS)
1/ advanced code templates in Ekeko/X 
2/ formal operators for template mutation 
3/ genetic search for mutation recommendations 
select parents 
mutation crossover 
16 2 Tree-based GP 
Parents Offspring 
3 
x y 
∗ 
+ 
y 1 
+ 
+ 
/ 
x 2 
Crossover 
Point 
Crossover 
Point 
3 
+ 
/ 
x 2 
(x+y)+3 
(y+1)* (x/2) 
(x/2)+3 
GARBAGE 
Figure 2.5: Example of subtree crossover. Note that the trees on the left 
are actually copies of the parents. So, their genetic material can freely be 
used without altering the original individuals. 
[Genetic programming, a field guide] 
to crossover operations frequently exchanging only very small amounts of 
genetic material (i.e., small subtrees); many crossovers may in fact reduce
1/ advanced code templates in Ekeko/X 
2/ formal operators for template mutation 
3/ genetic search for mutation recommendations 
desired 
best templates after 30 iterations 
[public void acceptVisitor(ComponentVisitor v);]@[(invoked-by ?v17892744)] 
comp.acceptVisitor(v) 
0.91 
[public void acceptVisitor(ComponentVisitor v){ 
...}]@[(invoked-by ?v20420073)] 
comp.acceptVisitor(v) 
0.91 
[public void acceptVisitor(ComponentVisitor v) ??v23406365]@[(invoked-by ??v23499077)] 
?v23184877(v) 
0.90 
[public void acceptVisitor(ComponentVisitor v)…]@[(equals ?method)] 
[….acceptVisitor(…)]@[(invokes ?method)]
Ongoing Experiment 
finetuning: very sensitive to probabilities of crossover and 
mutation, quality of RNG, diversity in population, … 
RQ1: how effective is the search in finding 
template changes? 
RQ2: do users find the recommended changes helpful? 
RQ3: do composite, template-specific mutations 
converge more quickly to a solution than generic code 
mutations?
recommending edits

Weitere ähnliche Inhalte

Was ist angesagt?

Generic Programming in java
Generic Programming in javaGeneric Programming in java
Generic Programming in javaGarik Kalashyan
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An OverviewIndrajit Das
 
Java - Generic programming
Java - Generic programmingJava - Generic programming
Java - Generic programmingRiccardo Cardin
 
On Parameterised Types and Java Generics
On Parameterised Types and Java GenericsOn Parameterised Types and Java Generics
On Parameterised Types and Java GenericsYann-Gaël Guéhéneuc
 
Generics and collections in Java
Generics and collections in JavaGenerics and collections in Java
Generics and collections in JavaGurpreet singh
 
Qcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharpQcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharpMichael Stal
 
Qcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scalaQcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scalaMichael Stal
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentalsHCMUTE
 
OODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsOODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsShanmuganathan C
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency ConstructsTed Leung
 
Programming in Scala - Lecture Two
Programming in Scala - Lecture TwoProgramming in Scala - Lecture Two
Programming in Scala - Lecture TwoAngelo Corsaro
 
Programming in Scala - Lecture One
Programming in Scala - Lecture OneProgramming in Scala - Lecture One
Programming in Scala - Lecture OneAngelo Corsaro
 
Effective Java - Generics
Effective Java - GenericsEffective Java - Generics
Effective Java - GenericsRoshan Deniyage
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++Amresh Raj
 
Java Generics
Java GenericsJava Generics
Java Genericsjeslie
 
Jdk1.5 Features
Jdk1.5 FeaturesJdk1.5 Features
Jdk1.5 Featuresindia_mani
 

Was ist angesagt? (20)

C++ interview question
C++ interview questionC++ interview question
C++ interview question
 
Generic Programming in java
Generic Programming in javaGeneric Programming in java
Generic Programming in java
 
DSD
DSDDSD
DSD
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
 
Java - Generic programming
Java - Generic programmingJava - Generic programming
Java - Generic programming
 
On Parameterised Types and Java Generics
On Parameterised Types and Java GenericsOn Parameterised Types and Java Generics
On Parameterised Types and Java Generics
 
Generics and collections in Java
Generics and collections in JavaGenerics and collections in Java
Generics and collections in Java
 
Qcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharpQcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharp
 
Qcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scalaQcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scala
 
Java generics final
Java generics finalJava generics final
Java generics final
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
OODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsOODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objects
 
C++ programing lanuage
C++ programing lanuageC++ programing lanuage
C++ programing lanuage
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency Constructs
 
Programming in Scala - Lecture Two
Programming in Scala - Lecture TwoProgramming in Scala - Lecture Two
Programming in Scala - Lecture Two
 
Programming in Scala - Lecture One
Programming in Scala - Lecture OneProgramming in Scala - Lecture One
Programming in Scala - Lecture One
 
Effective Java - Generics
Effective Java - GenericsEffective Java - Generics
Effective Java - Generics
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Jdk1.5 Features
Jdk1.5 FeaturesJdk1.5 Features
Jdk1.5 Features
 

Andere mochten auch

Power Point for Technology Special Ed Class
Power Point for Technology Special Ed ClassPower Point for Technology Special Ed Class
Power Point for Technology Special Ed ClassMichelle Ruxton
 
Avoiding Overgeneralizing
Avoiding OvergeneralizingAvoiding Overgeneralizing
Avoiding OvergeneralizingRuthiee
 
Generalizations of the auxiliary particle filter for multiple target tracking
Generalizations of the auxiliary particle filter for multiple target trackingGeneralizations of the auxiliary particle filter for multiple target tracking
Generalizations of the auxiliary particle filter for multiple target trackingLuis Úbeda Medina
 
making generalizations
making generalizationsmaking generalizations
making generalizationsvxiiayah
 
Making Generalizations
Making GeneralizationsMaking Generalizations
Making GeneralizationsIron Man
 
Goursat's Lemma Presentation
Goursat's Lemma PresentationGoursat's Lemma Presentation
Goursat's Lemma PresentationCaridad Arroyo
 
Standardized Test Prep
Standardized Test PrepStandardized Test Prep
Standardized Test Preptar358
 
4 facts, concepts and generalizations jan 19
4 facts, concepts and generalizations jan 194 facts, concepts and generalizations jan 19
4 facts, concepts and generalizations jan 19kelsey02
 
Generalization and example
Generalization and exampleGeneralization and example
Generalization and exampleNaeem Hassan
 
Making Generalizations
Making GeneralizationsMaking Generalizations
Making Generalizationsazwoyer
 
Making generalizations
Making generalizationsMaking generalizations
Making generalizationsgherm6
 
Generalization and types
Generalization and typesGeneralization and types
Generalization and typesNaeem Hassan
 
A detailed lesson plan in english
A detailed lesson plan in englishA detailed lesson plan in english
A detailed lesson plan in englishGlenn Ryan Zausa
 

Andere mochten auch (20)

Power Point for Technology Special Ed Class
Power Point for Technology Special Ed ClassPower Point for Technology Special Ed Class
Power Point for Technology Special Ed Class
 
802.16.Traffic Model
802.16.Traffic Model802.16.Traffic Model
802.16.Traffic Model
 
Avoiding Overgeneralizing
Avoiding OvergeneralizingAvoiding Overgeneralizing
Avoiding Overgeneralizing
 
Generalizations of the auxiliary particle filter for multiple target tracking
Generalizations of the auxiliary particle filter for multiple target trackingGeneralizations of the auxiliary particle filter for multiple target tracking
Generalizations of the auxiliary particle filter for multiple target tracking
 
making generalizations
making generalizationsmaking generalizations
making generalizations
 
Making Generalizations
Making GeneralizationsMaking Generalizations
Making Generalizations
 
Goursat's Lemma Presentation
Goursat's Lemma PresentationGoursat's Lemma Presentation
Goursat's Lemma Presentation
 
Standardized Test Prep
Standardized Test PrepStandardized Test Prep
Standardized Test Prep
 
Generalizing
GeneralizingGeneralizing
Generalizing
 
4 facts, concepts and generalizations jan 19
4 facts, concepts and generalizations jan 194 facts, concepts and generalizations jan 19
4 facts, concepts and generalizations jan 19
 
Generalization and example
Generalization and exampleGeneralization and example
Generalization and example
 
Making Generalizations
Making GeneralizationsMaking Generalizations
Making Generalizations
 
An anecdote
An anecdoteAn anecdote
An anecdote
 
Making generalizations
Making generalizationsMaking generalizations
Making generalizations
 
What is Generalization
What is GeneralizationWhat is Generalization
What is Generalization
 
Lesson planning
Lesson planningLesson planning
Lesson planning
 
DETAILED LESSON PLAN IN ENGLISH GRADE 10
DETAILED LESSON PLAN IN ENGLISH GRADE 10DETAILED LESSON PLAN IN ENGLISH GRADE 10
DETAILED LESSON PLAN IN ENGLISH GRADE 10
 
Generalization and types
Generalization and typesGeneralization and types
Generalization and types
 
Sample Detailed Lesson Plan
Sample Detailed Lesson PlanSample Detailed Lesson Plan
Sample Detailed Lesson Plan
 
A detailed lesson plan in english
A detailed lesson plan in englishA detailed lesson plan in english
A detailed lesson plan in english
 

Ähnlich wie A recommender system for generalizing and refining code templates

Two methods for optimising cognitive model parameters
Two methods for optimising cognitive model parametersTwo methods for optimising cognitive model parameters
Two methods for optimising cognitive model parametersUniversity of Huddersfield
 
SystemVerilog-20041201165354.ppt
SystemVerilog-20041201165354.pptSystemVerilog-20041201165354.ppt
SystemVerilog-20041201165354.pptravi446393
 
Matlab Functions
Matlab FunctionsMatlab Functions
Matlab FunctionsUmer Azeem
 
Introduction to Boost regex
Introduction to Boost regexIntroduction to Boost regex
Introduction to Boost regexYongqiang Li
 
Generics Past, Present and Future (Latest)
Generics Past, Present and Future (Latest)Generics Past, Present and Future (Latest)
Generics Past, Present and Future (Latest)RichardWarburton
 
Functional Smalltalk
Functional SmalltalkFunctional Smalltalk
Functional SmalltalkESUG
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesCHOOSE
 
walkmod - JUG talk
walkmod - JUG talkwalkmod - JUG talk
walkmod - JUG talkwalkmod
 
Functions in C++
Functions in C++Functions in C++
Functions in C++home
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side JavascriptJulie Iskander
 
Sedna XML Database: Query Parser & Optimizing Rewriter
Sedna XML Database: Query Parser & Optimizing RewriterSedna XML Database: Query Parser & Optimizing Rewriter
Sedna XML Database: Query Parser & Optimizing RewriterIvan Shcheklein
 
Fpga 06-data-types-system-tasks-compiler-directives
Fpga 06-data-types-system-tasks-compiler-directivesFpga 06-data-types-system-tasks-compiler-directives
Fpga 06-data-types-system-tasks-compiler-directivesMalik Tauqir Hasan
 
Patterns in Python
Patterns in PythonPatterns in Python
Patterns in Pythondn
 
Breaking down data silos with the open data protocol
Breaking down data silos with the open data protocolBreaking down data silos with the open data protocol
Breaking down data silos with the open data protocolWoodruff Solutions LLC
 
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...Francesco Casalegno
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard LibrarySantosh Rajan
 

Ähnlich wie A recommender system for generalizing and refining code templates (20)

Two methods for optimising cognitive model parameters
Two methods for optimising cognitive model parametersTwo methods for optimising cognitive model parameters
Two methods for optimising cognitive model parameters
 
SystemVerilog-20041201165354.ppt
SystemVerilog-20041201165354.pptSystemVerilog-20041201165354.ppt
SystemVerilog-20041201165354.ppt
 
Matlab Functions
Matlab FunctionsMatlab Functions
Matlab Functions
 
VB.net
VB.netVB.net
VB.net
 
Introduction to Boost regex
Introduction to Boost regexIntroduction to Boost regex
Introduction to Boost regex
 
Modern C++
Modern C++Modern C++
Modern C++
 
R Basics
R BasicsR Basics
R Basics
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
 
Generics Past, Present and Future (Latest)
Generics Past, Present and Future (Latest)Generics Past, Present and Future (Latest)
Generics Past, Present and Future (Latest)
 
Functional Smalltalk
Functional SmalltalkFunctional Smalltalk
Functional Smalltalk
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
 
walkmod - JUG talk
walkmod - JUG talkwalkmod - JUG talk
walkmod - JUG talk
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
Sedna XML Database: Query Parser & Optimizing Rewriter
Sedna XML Database: Query Parser & Optimizing RewriterSedna XML Database: Query Parser & Optimizing Rewriter
Sedna XML Database: Query Parser & Optimizing Rewriter
 
Fpga 06-data-types-system-tasks-compiler-directives
Fpga 06-data-types-system-tasks-compiler-directivesFpga 06-data-types-system-tasks-compiler-directives
Fpga 06-data-types-system-tasks-compiler-directives
 
Patterns in Python
Patterns in PythonPatterns in Python
Patterns in Python
 
Breaking down data silos with the open data protocol
Breaking down data silos with the open data protocolBreaking down data silos with the open data protocol
Breaking down data silos with the open data protocol
 
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard Library
 

Mehr von Coen De Roover

A logic foundation for template-based program transformation in Eclipse
A logic foundation for template-based program transformation in EclipseA logic foundation for template-based program transformation in Eclipse
A logic foundation for template-based program transformation in EclipseCoen De Roover
 
The Cha-Q Meta-Model: A Comprehensive, Change-Centric Software Representation
The Cha-Q Meta-Model: A Comprehensive, Change-Centric Software RepresentationThe Cha-Q Meta-Model: A Comprehensive, Change-Centric Software Representation
The Cha-Q Meta-Model: A Comprehensive, Change-Centric Software RepresentationCoen De Roover
 
CrimeSPOT: Language Support for Programming Interactions among Wireless Senso...
CrimeSPOT: Language Support for Programming Interactions among Wireless Senso...CrimeSPOT: Language Support for Programming Interactions among Wireless Senso...
CrimeSPOT: Language Support for Programming Interactions among Wireless Senso...Coen De Roover
 
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...Coen De Roover
 
The STADiUM language framework for capturing domain-specific interaction patt...
The STADiUM language framework for capturing domain-specific interaction patt...The STADiUM language framework for capturing domain-specific interaction patt...
The STADiUM language framework for capturing domain-specific interaction patt...Coen De Roover
 
UbiLab@SOFT: A tale of ubiquitous bears, flyswatters 
and punching bags in ed...
UbiLab@SOFT: A tale of ubiquitous bears, flyswatters 
and punching bags in ed...UbiLab@SOFT: A tale of ubiquitous bears, flyswatters 
and punching bags in ed...
UbiLab@SOFT: A tale of ubiquitous bears, flyswatters 
and punching bags in ed...Coen De Roover
 
Logic-based program transformation in symbiosis with Eclipse
Logic-based program transformation in symbiosis with EclipseLogic-based program transformation in symbiosis with Eclipse
Logic-based program transformation in symbiosis with EclipseCoen De Roover
 

Mehr von Coen De Roover (7)

A logic foundation for template-based program transformation in Eclipse
A logic foundation for template-based program transformation in EclipseA logic foundation for template-based program transformation in Eclipse
A logic foundation for template-based program transformation in Eclipse
 
The Cha-Q Meta-Model: A Comprehensive, Change-Centric Software Representation
The Cha-Q Meta-Model: A Comprehensive, Change-Centric Software RepresentationThe Cha-Q Meta-Model: A Comprehensive, Change-Centric Software Representation
The Cha-Q Meta-Model: A Comprehensive, Change-Centric Software Representation
 
CrimeSPOT: Language Support for Programming Interactions among Wireless Senso...
CrimeSPOT: Language Support for Programming Interactions among Wireless Senso...CrimeSPOT: Language Support for Programming Interactions among Wireless Senso...
CrimeSPOT: Language Support for Programming Interactions among Wireless Senso...
 
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
 
The STADiUM language framework for capturing domain-specific interaction patt...
The STADiUM language framework for capturing domain-specific interaction patt...The STADiUM language framework for capturing domain-specific interaction patt...
The STADiUM language framework for capturing domain-specific interaction patt...
 
UbiLab@SOFT: A tale of ubiquitous bears, flyswatters 
and punching bags in ed...
UbiLab@SOFT: A tale of ubiquitous bears, flyswatters 
and punching bags in ed...UbiLab@SOFT: A tale of ubiquitous bears, flyswatters 
and punching bags in ed...
UbiLab@SOFT: A tale of ubiquitous bears, flyswatters 
and punching bags in ed...
 
Logic-based program transformation in symbiosis with Eclipse
Logic-based program transformation in symbiosis with EclipseLogic-based program transformation in symbiosis with Eclipse
Logic-based program transformation in symbiosis with Eclipse
 

Kürzlich hochgeladen

FREE NURSING BUNDLE FOR NURSES.PDF by na
FREE NURSING BUNDLE FOR NURSES.PDF by naFREE NURSING BUNDLE FOR NURSES.PDF by na
FREE NURSING BUNDLE FOR NURSES.PDF by naJASISJULIANOELYNV
 
Environmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial BiosensorEnvironmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial Biosensorsonawaneprad
 
basic entomology with insect anatomy and taxonomy
basic entomology with insect anatomy and taxonomybasic entomology with insect anatomy and taxonomy
basic entomology with insect anatomy and taxonomyDrAnita Sharma
 
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxLIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxmalonesandreagweneth
 
《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》rnrncn29
 
Harmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms PresentationHarmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms Presentationtahreemzahra82
 
Observational constraints on mergers creating magnetism in massive stars
Observational constraints on mergers creating magnetism in massive starsObservational constraints on mergers creating magnetism in massive stars
Observational constraints on mergers creating magnetism in massive starsSérgio Sacani
 
trihybrid cross , test cross chi squares
trihybrid cross , test cross chi squarestrihybrid cross , test cross chi squares
trihybrid cross , test cross chi squaresusmanzain586
 
ECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptx
ECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptxECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptx
ECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptxmaryFF1
 
Pests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPirithiRaju
 
Base editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editingBase editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editingNetHelix
 
OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024innovationoecd
 
Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024AyushiRastogi48
 
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxSTOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxMurugaveni B
 
Speech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxSpeech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxpriyankatabhane
 
Topic 9- General Principles of International Law.pptx
Topic 9- General Principles of International Law.pptxTopic 9- General Principles of International Law.pptx
Topic 9- General Principles of International Law.pptxJorenAcuavera1
 
Pests of jatropha_Bionomics_identification_Dr.UPR.pdf
Pests of jatropha_Bionomics_identification_Dr.UPR.pdfPests of jatropha_Bionomics_identification_Dr.UPR.pdf
Pests of jatropha_Bionomics_identification_Dr.UPR.pdfPirithiRaju
 
PROJECTILE MOTION-Horizontal and Vertical
PROJECTILE MOTION-Horizontal and VerticalPROJECTILE MOTION-Horizontal and Vertical
PROJECTILE MOTION-Horizontal and VerticalMAESTRELLAMesa2
 
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...Universidade Federal de Sergipe - UFS
 

Kürzlich hochgeladen (20)

FREE NURSING BUNDLE FOR NURSES.PDF by na
FREE NURSING BUNDLE FOR NURSES.PDF by naFREE NURSING BUNDLE FOR NURSES.PDF by na
FREE NURSING BUNDLE FOR NURSES.PDF by na
 
Environmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial BiosensorEnvironmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial Biosensor
 
basic entomology with insect anatomy and taxonomy
basic entomology with insect anatomy and taxonomybasic entomology with insect anatomy and taxonomy
basic entomology with insect anatomy and taxonomy
 
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxLIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
 
《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》
 
Harmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms PresentationHarmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms Presentation
 
Observational constraints on mergers creating magnetism in massive stars
Observational constraints on mergers creating magnetism in massive starsObservational constraints on mergers creating magnetism in massive stars
Observational constraints on mergers creating magnetism in massive stars
 
trihybrid cross , test cross chi squares
trihybrid cross , test cross chi squarestrihybrid cross , test cross chi squares
trihybrid cross , test cross chi squares
 
ECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptx
ECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptxECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptx
ECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptx
 
Pests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdf
 
Base editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editingBase editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editing
 
OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024
 
Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024
 
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxSTOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
 
Speech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxSpeech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptx
 
Topic 9- General Principles of International Law.pptx
Topic 9- General Principles of International Law.pptxTopic 9- General Principles of International Law.pptx
Topic 9- General Principles of International Law.pptx
 
Pests of jatropha_Bionomics_identification_Dr.UPR.pdf
Pests of jatropha_Bionomics_identification_Dr.UPR.pdfPests of jatropha_Bionomics_identification_Dr.UPR.pdf
Pests of jatropha_Bionomics_identification_Dr.UPR.pdf
 
PROJECTILE MOTION-Horizontal and Vertical
PROJECTILE MOTION-Horizontal and VerticalPROJECTILE MOTION-Horizontal and Vertical
PROJECTILE MOTION-Horizontal and Vertical
 
Volatile Oils Pharmacognosy And Phytochemistry -I
Volatile Oils Pharmacognosy And Phytochemistry -IVolatile Oils Pharmacognosy And Phytochemistry -I
Volatile Oils Pharmacognosy And Phytochemistry -I
 
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
 

A recommender system for generalizing and refining code templates

  • 1. A recommender system for generalizing and refining code templates Towards Coen De Roover, Tim Molderez
  • 2. User-specified templates are ubiquitous code transformation code generation code search
  • 3. Life without templates? manual implementations Imperative Program Transformation by Rewriting It says that an assignment x := v (where v is a variable) can x := c if the “last assignment” to v was v := c (where c is a constant). condition formalises the notion of “last assignment”, and will be the paper: tools taking exotic specifications n : (x := v) =⇒ x := c if n ⊢ A△(¬def(v) U def(v) ∧ stmt(v := c)) conlit(c)
  • 4. But specifying templates is still hard… code template source code + meta-variables + matching directives often requires multiple iterations no required matches are missed generalization no unwanted matches refinement no support for editing process no disciplined methods for generalizing/refining templates no automated support in the form of recommender system
  • 5. I’m a “structural search and replace” on steroids 1/ advanced code templates in Ekeko/X 2/ formal operators for template mutation 3/ genetic search for mutation recommendations
  • 6. 1/ advanced code templates in Ekeko/X 2/ formal operators for template mutation 3/ genetic search for mutation recommendations template matches
  • 7. 1/ advanced code templates in Ekeko/X 2/ formal operators for template mutation 3/ genetic search for mutation recommendations template matches
  • 8. 1/ advanced code templates in Ekeko/X 2/ formal operators for template mutation 3/ genetic search for mutation recommendations template matches [<component>]@[<directive>]
  • 9. [<component>]@[<directive>] constraining syntax, structure, data flow, control flow of matches match any match is in source code, with matching type and properties orsimple qualified name match is any name resolving to name in template (equals ?var) any exposes match child, child+, child* any match is corresponding child of parent match, nested within that child (+), or either (*) match|set list match has at least given elements, in any order match|regexp list match has elements described by regexp (type ?type) type/variable declaration/reference expression match resolves to, is of, or declares the type of its argument (subtype ?type), (subtype+ ?type), (subtype* /type) type/variable declaration/reference match resolves to a (transitive +, reflexive *) subtype of the given argument (refers-to ?var) expression match lexically refers to local, parameter or field denoted by its argument (invokes ?method) invocation expression match invokes given argument grouping of templates [public void acceptVisitor(ComponentVisitor v)…]@[(equals ?method)] [….acceptVisitor(…)]@[(invokes ?method)]
  • 10. 1/ advanced code templates in Ekeko/X 2/ formal operators for template mutation 3/ genetic search for mutation recommendations ? ? ?
  • 11. 1/ advanced code templates in Ekeko/X 2/ formal operators for template mutation 3/ genetic search for mutation recommendations introduce-variable return age; return ?v; atomic mutation generalize-aliases composite mutation public class Book { private Integer count; public Integer getCount() { return count; } } public class Book { private Integer ?v1; public Integer getCount() { return [?v2]@[(refers-to ?v1)]; } }
  • 12. 1/ advanced code templates in Ekeko/X 2/ formal operators for template mutation 3/ genetic search for mutation recommendations (Operator. "remove-node" operators/remove-node :destructive "Remove from template." opscope-subject applicability|deleteable "Removes its selection from the template." []) (Operator. constraints on their subject "add-directive-invokes" operators/add-directive-invokes :refinement "Add directive invokes." opscope-subject applicability|methodinvocation "Requires matches to invoke the binding for the meta-variable." [(make-operand "Meta-variable (e.g., ?v)" opscope-variable validity|variable)]) constraints on their operands constraints enable checking applicability of operator, validity of its operands + generating possible values!
  • 13. 1/ advanced code templates in Ekeko/X 2/ formal operators for template mutation 3/ genetic search for mutation recommendations given enumeration of desired matches populate determine fitness best individual good enough? select parents crossover & mutation yay!
  • 14. 1/ advanced code templates in Ekeko/X 2/ formal operators for template mutation 3/ genetic search for mutation recommendations populate individual = group of templates - copies of existing group (from editor state) - one template group per row, consisting of a template per column in desired matches (from scratch)
  • 15. 1/ advanced code templates in Ekeko/X 2/ formal operators for template mutation 3/ genetic search for mutation recommendations determine fitness concurrently! a) match each template group in population against program b) determine precision and recall w.r.t. desired matches c) penalize excess use of directives (KISS)
  • 16. 1/ advanced code templates in Ekeko/X 2/ formal operators for template mutation 3/ genetic search for mutation recommendations select parents mutation crossover 16 2 Tree-based GP Parents Offspring 3 x y ∗ + y 1 + + / x 2 Crossover Point Crossover Point 3 + / x 2 (x+y)+3 (y+1)* (x/2) (x/2)+3 GARBAGE Figure 2.5: Example of subtree crossover. Note that the trees on the left are actually copies of the parents. So, their genetic material can freely be used without altering the original individuals. [Genetic programming, a field guide] to crossover operations frequently exchanging only very small amounts of genetic material (i.e., small subtrees); many crossovers may in fact reduce
  • 17. 1/ advanced code templates in Ekeko/X 2/ formal operators for template mutation 3/ genetic search for mutation recommendations desired best templates after 30 iterations [public void acceptVisitor(ComponentVisitor v);]@[(invoked-by ?v17892744)] comp.acceptVisitor(v) 0.91 [public void acceptVisitor(ComponentVisitor v){ ...}]@[(invoked-by ?v20420073)] comp.acceptVisitor(v) 0.91 [public void acceptVisitor(ComponentVisitor v) ??v23406365]@[(invoked-by ??v23499077)] ?v23184877(v) 0.90 [public void acceptVisitor(ComponentVisitor v)…]@[(equals ?method)] [….acceptVisitor(…)]@[(invokes ?method)]
  • 18. Ongoing Experiment finetuning: very sensitive to probabilities of crossover and mutation, quality of RNG, diversity in population, … RQ1: how effective is the search in finding template changes? RQ2: do users find the recommended changes helpful? RQ3: do composite, template-specific mutations converge more quickly to a solution than generic code mutations?
  • 19.