Experiments with Pro-Active Declarative Meta-Programming

13
Verónica Uquillas Gómez Andy Kellens Kris Gybels Theo D’Hondt Experiments with Pro-Active Declarative Meta-Programming Software Languages Lab Vrije Universiteit Brussel Belgium International Workshop on Smalltalk Technologies 31st of August 2009, Brest - France ESUG 2009

description

Experiments with Pro-Active Declarative Meta-Programming by Verónica Uquillas Gómez. ESUG09, Brest, France

Transcript of Experiments with Pro-Active Declarative Meta-Programming

Page 1: Experiments with Pro-Active Declarative Meta-Programming

Verónica Uquillas Gómez Andy Kellens Kris Gybels

Theo D’Hondt

Experiments with Pro-Active Declarative Meta-Programming

Software Languages Lab Vrije Universiteit Brussel

Belgium

International Workshop on Smalltalk Technologies 31st of August 2009, Brest - France ESUG 2009

Page 2: Experiments with Pro-Active Declarative Meta-Programming

Problem

  Developer-driven ( pro-active)   Snapshot-based reasoning ( time)

Page 3: Experiments with Pro-Active Declarative Meta-Programming

SOUL: Smalltalk Open Unification Language

  Query language   Prolog-like   Smalltalk, Java,

C(++), Cobol

class(?class) if member(?class, [Smalltalk allClasses])

Page 4: Experiments with Pro-Active Declarative Meta-Programming

PARACHUT: Programming And Reasoning About CHanges Using Time

… Ch1 Chn Ch2 Ch3 TIME

if subclassOf(?subclass, ?superclass), ….

Page 5: Experiments with Pro-Active Declarative Meta-Programming

Backward Chaining vs. Forward Chaining

  More possible start states or goal states?   What kind of events triggers problem-solving?

Goal-driven Data-driven

Page 6: Experiments with Pro-Active Declarative Meta-Programming

Example: hash – equal rule

classNeedsHash(?class) if methodInClass(?class, =), not(methodInClass(?class, hash))

classNeedsEqual(?class) if methodInClass(?class, hash), not(methodInClass(?class, =))

  class

  instanceVariableInClass

  methodInClass

  methodCallsMethod

  classInPackage

  subclassOf

  classInHierarchyOf

“re-implementing the = method implies re-implementing the hash method”

Page 7: Experiments with Pro-Active Declarative Meta-Programming

PARACHUT: defining the declarative queries

Page 8: Experiments with Pro-Active Declarative Meta-Programming

PARACHUT: outputs to developers (I)

Page 9: Experiments with Pro-Active Declarative Meta-Programming

PARACHUT: outputs to developers (II)

Page 10: Experiments with Pro-Active Declarative Meta-Programming

Other Examples

  Pulsar class pattern

  Possible refactoring opportunities

Page 11: Experiments with Pro-Active Declarative Meta-Programming

Pulsar Class Pattern

pulsar(?class) if pulsar(?class, ?len3, ?len2, ?len1)

pulsar(?class, ?len3, ?len2, ?len1) if allConsecutiveSizes(?class, ?len3, ?len2, ?len1),

escape(?val, [(?len1 * 2) = ?len2

and:[ ?len1 = ?len3]])

TIME

Pulsar class

Page 12: Experiments with Pro-Active Declarative Meta-Programming

Detecting possible refactoring opportunities

duplicateSelector(?classA, ?classB, ?method) if addedMethodInClass(?classB, ?method), mostrecent(addedMethodInClass(?classA, ?method))

refactoringOpportunity(?superclass, ?method) if duplicatedSelector(?classA, ?classB, ?method), subclassOf(?classA, ?superclass), subclassOf(?classB, ?superclass), not(addedMethodInClass(?superclass, ?method))

Page 13: Experiments with Pro-Active Declarative Meta-Programming

Conclusions

if subclassOf(?subclass, ?superclass), ….

Ch1 Chn Ch2 Ch3 TIME

Verónica Uquillas Gómez [email protected]