SlideShare a Scribd company logo
1 of 22
Download to read offline
1
Three musketeers to the rescue
Meta-modelling, Logic Programming, and Explanation-based
Constraint Programming for Pattern Description and Detection
Yann-Gaël Guéhéneuc
guehene@emn.fr
Object Technology
International, Inc., Canada
École des Mines
de Nantes, France
Hello, my name is … from the École des Mines de Nantes.
My work is partly funded by OTI.
Today, I present three distinct meta-declarative programming techniques we develop and
use for our research on patterns.
This presentation has been given at the ASE 2002 workshop on Declarative Meta-Programming
2
2/18
The musketeers were French…
Do not hesitate to
interrupt!
Questions are most
welcome!
Well, as the Three Musketeers, I am also French.
My accent might be a bit of a problem…
Do not hesitate to interrupt me and to ask questions!
3
3/18
Objectives of this presentation
Present our use of three declarative
meta-programming techniques
– Meta-modelling
– Meta-logic programming
– Explanation-based constraint programming
Context, example, advantages/drawbacks
Discuss these techniques, their
limitations, their use in other contexts
In our research, we use three declarative meta-programming techniques :
-Meta-modelling.
-Meta-logic programming.
-Explanation-based constraint programming.
We use these techniques for the description, application, and detection of design patterns
and design defects.
First, I introduce the context of our research.
Then, I present each of these declarative meta-programming techniques.
I also give an example and the reasons why it is a declarative meta-programming
technique.
I also discuss some of its advantages and drawbacks.
Finally, I wish to discuss with you these techniques, their limitations, other better
techniques, other possible applications…
4
4/18
Context of our research
Design patterns
⇒ Design defects
⇒ Patterns
Patterns description
Pattern application
(design patterns only! ☺)
Pattern detection
We work on design patterns and design defects.
Design patterns are “descriptions of communicating objects and classes that are
customized to solve a general design problem in a particular context” ([Gamma, 1994],
page 3).
Design patterns describe a problem, a solution, and the consequences when applying the
solutions.
The solution of a design pattern is generally represented with OMT diagrams and source
code examples; That is the solution of a design pattern is generally represented with a
micro-architecture exemplifying the solution.
We argue that:
-Design defects are similar to design patterns and we can represent them as design
patterns.
-A micro-architecture close but not identical to the solution of a design pattern represent
a possible design defects.
We call design patterns and design defect “patterns”.
We want to describe patterns (the micro-architectures representing the solutions of
design patterns, or representing design defects).
We want to apply design patterns from descriptions of design patterns.
We want to detect complete forms of design patterns, distorted forms of design patterns,
and design defects.
5
5/18
Meta-modelling (1/4)
Pattern Description Language (PDL):
– A meta-model
– Abstract models of patterns
An abstract model is a first class entity:
– We can parameterize it (PatternsBox)
– It can generate its corresponding code
– It can detect complete micro-architectures
that are similar to itself
We develop Pattern Description Language (PDL), a meta-model to describe abstract
models of patterns.
An abstract model is declared using constituents of PDL.
An abstract model represents the micro-architecture solution of a pattern.
We can parameterize an abstract model to obtain a concrete model of a pattern, using for
example PatternsBox.
We can ask an abstract model (or a concrete model) to generate itself, for example as
Java source code, as constraint system, or as an input for other tools.
We can ask an abstract model to detect itself in a given Java program architecture
(source code/class files).
When an abstract model detects itself, we obtain concrete models of the pattern.
6
6/18
Meta-modelling (2/4)
Translates into
Informal descriptions
from [Gamma, 1994]
Instance of Interface
Instance of Class
Instance of Association
Instance of Delegation
name() Instance of Method
Instance of Pattern
Here is a simple example of an abstract model.
This abstract model describes the Composite design pattern.
We describe the micro-architecture solution advocated by the Composite design pattern
and the informal information using constituents of the meta-model.
7
7/18
Meta-modelling (3/4)
public Composite() throws
CloneNotSupportedException,
PatternDeclarationException {
super();
final Class aClass;
final Interface anInterface;
final DelegatingMethod aDelegatingMethod;
final Method abMethod;
// Interface Component.
anInterface = new Interface("Component");
this.addEntity(anInterface);
abMethod = new Method("Operation");
anInterface.addElement(abMethod);
// Association children.
final Composition aComposition =
new Composition("children", anInterface, 2);
// Class Composite.
aClass = new Class("Composite");
this.addEntity(aClass);
aClass.addImplementedEntity(anInterface);
aClass.addElement(aComposition);
aDelegatingMethod = new DelegatingMethod(
"Operation",
aComposition);
aDelegatingMethod.attachTo(abMethod);
aClass.addElement(aDelegatingMethod);
// Class Leaf.
this.addLeaf(new String[] { "Leaf" });
}
Here is the source code describing the Composite design pattern.
It is declarative because each abstract model is declared by a sequence of statements.
It is meta because the statements are instances of constituents of the meta-model.
It is programming because we use the abstract model programmatically to reason about
the design pattern solution.
8
8/18
Meta-modelling (4/4)
Advantages:
– Patterns are first-class entities
– Patterns embody all the logic
Drawbacks:
– The meta-model only describes one
perspective on patterns
Advantages:
-Patterns are first-class entities.
-Patterns descriptions embody all the logic related to patterns (application, detection).
Drawbacks:
-The meta-model only describes one perspective on patterns. For example, PDL only
describes the structure of patterns (and some behavioural information).
9
9/18
Meta-logic programming (1/4)
Caffeine is a program for trace analysis
of Java programs
Caffeine is based on:
– A model of trace
– A model of execution events that abstracts
the program execution
– The JPDA
– A Prolog engine (JIProlog)
Caffeine is a tool for the analysis of Java programs.
It defines a model of trace: A trace is a history of execution events.
It defines a model of execution events: Execution events are emitted by the program
being analyzed and abstract the program behaviour.
It is a program that runs as a co-routine of a program to analyze.
It drives the program being analyzed using the JPDA (Java Platform Debug
Architecture).
It receives events from the program being analyzed as Prolog predicates and can reflect
on these events.
10
10/18
Meta-logic programming (2/4)
class A {
String s;
A(String s) {
…
}
String foo() {
…
return "Happy" + s;
}
protected void finalize() {
…
}
}
classLoad
+ classUnload
programEnd
fieldAccess
fieldModification
constructorEntry
constructorExit
methodEntry
methodExit
finalizerEntry
finalizerExit
Here is the list of execution events that can be emitted by the program being analyzed.
All these execution events might not be of interest, so we can filter out the events we are
not interested in.
Filtering out events improves slightly the performances of the program being analyzed.
11
11/18
Meta-logic programming (3/4)
nextPlaceNextQueen :-
nextMethodEntryEvent(N),
isPlaceNextQueen(N).
isPlaceNextQueen(placeNextQueen) :- !.
isPlaceNextQueen(removeQueen) :- !, fail.
isPlaceNextQueen(setQueen) :- !, fail.
isPlaceNextQueen(_) :- nextPlaceNextQueen.
query(N, M) :-
% I go to the next
% setQueen(...)
% placeNextQueen(...)
% removeQueen(...)
% triplet of events:
nextMethodEntryEvent(setQueen),
nextPlaceNextQueen,
nextMethodEntryEvent(removeQueen),
% I count the number of time I execute the query:
!,
N1 is N + 1,
query(N1, M).
query(N, N).
Here is the source code counting the number of times the program being analyzed
performs a sequence of method invocations.
It is declarative because the analysis is declared by a sequence of predicates.
It is meta because the predicates abstract the execution of the program being analyzed.
It is programming because we use this analysis programmatically to reason about the
program execution.
LINK WITH SOUL (http://prog.vub.ac.be/research/DMP/soul/soul2.html)
12
12/18
Meta-logic programming (4/4)
Advantages:
– Powerful
Drawbacks:
– No universal quantifiers
– No temporal relationships
– Performances
Advantages:
-Powerful and natural expressions of queries.
Drawbacks:
-No universal quantifiers.
-No temporal relationships.
-Performances.
13
13/18
Explanation-based constraint
programming (1/4)
Abstract models of design defects
ONE Assumption:
– Micro-architectures similar but not identical
to design pattern solutions might be:
• Distorted because clumsily implemented
• Distorted because not fit
• Something else, sorry! ☺
An explanation-based constraint solver:
Ptidej Solver (PaLM)
Using PDL, we describe abstract model of design defects.
We also make one assumption: Micro-architectures that are similar but not identical to
design pattern solutions are:
-Either distorted design patterns because the design patterns are clumsily implemented.
-Or distorted design patterns because the design patterns do not fit in the architecture.
-Or something else, but it is still worth to know that it looked like some design pattern!
So, we want to detect distorted micro-architectures in a given program architecture. We
use explanation-based constraint programming. Explanation-based constraint
programming is basically constraint programming, except that when there is no more
solutions (i.e., a contradiction), the solver knows why: It knows the constraints that led to
the contradiction. We can remove from the constraint systems the constraints leading to
the contradiction and obtain more distorted solutions to the problem.
We develop an explanation-based constraint solver: Ptidej Solver. Ptidej Solver is based
on the PaLM explanation-based constraint solver, PaLM is the reference implementation
regarding explanation-based constraint programming.
14
14/18
Explanation-based constraint
programming (2/4)
[ac4ProblemForCompositePattern() : PtidejProblem ->
let pb := makePtidejProblem("Composite Pattern Problem", length(listOfEntities), 90),
compositeRoot := makePtidejIntVar(pb, "CompositeRoot", 1, length(listOfEntities)),
component := makePtidejIntVar(pb, "Component", 1, length(listOfEntities)),
composite := makePtidejIntVar(pb, "Composite", 1, length(listOfEntities), false),
leaf := makePtidejIntVar(pb, "Leaf", 1, length(listOfEntities), false) in (
post(pb, makeCompositionAC4Constraint("CompositeRoot <>--> Component", "...", compositeRoot, component), 90),
post(pb, makeInheritanceAC4Constraint("CompositeRoot -|>- Component", "...", compositeRoot, component), 60),
post(pb, makeInheritanceAC4Constraint("Composite -|>- CompositeRoot", "...", composite, compositeRoot), 90),
post(pb, makeInheritancePathAC4Constraint("Leaf -|>- ... -|>- Component", "", leaf, component), 90),
post(pb, makeIgnoranceAC4Constraint("Component -/--> Leaf", "...", component, leaf), 10),
post(pb, makeIgnoranceAC4Constraint("Leaf -/--> Composite", "...", leaf, composite), 30),
post(pb, makeNotEqualAC4Constraint("Component <> Leaf", "...", component, leaf), 100),
post(pb, makeNotEqualAC4Constraint("Composite <> Leaf", "...", composite, leaf), 100),
post(pb, makeNotEqualAC4Constraint("CompositeRoot <> Leaf", "...", compositeRoot, leaf), 100),
pb
)
]
Here is an example of the constraint system we use to detect complete and distorted
micro-architecture identical or similar to the Composite design pattern.
This constraint system is directly obtained from the abstract model of the Composite
design pattern.
First, we declare the problem.
Then, we declare the different variables.
Each variable represents an actor in the pattern.
In particular, the Composite and Leaf actor are declared as not enumerated, because their
roles may be filled by more than one entity in the software architecture.
Finally, we post the different constraints representing the Composite design pattern.
We associate a weight with each constraint to tell the Ptidej Solver which constraints it
can relax and which it can not.
It is declarative because the constraint system is declared by a sequence of constraints.
It is meta because the constraints apply on the architecture of the program.
It is programming because we use constraint systems programmatically to detect
complete and distorted forms of design patterns.
15
15/18
Explanation-based constraint
programming (3/4)
# Solution without constraint:
# -|>- : CompositeRoot -|>- Component
1.60.XCommand = Composite, Component |ntttjavaXL.XClass c1,
javaXL.XClass c2 |ntttc1.setSuperclass(c2.getName());
1.60.CompositeRoot = jtu.example.composite2.Document
1.60.Component = jtu.example.composite2.Element
1.60.Composite = jtu.example.composite2.Document
1.60.Leaf-1 = jtu.example.composite2.IndentedParagraph
1.60.Leaf-2 = jtu.example.composite2.Paragraph
1.60.Leaf-3 = jtu.example.composite2.Title
# Solved in 0min (130ms).
Here is some results from a simple text editor.
The solver computed first the solutions with all the constraints.
It appeared that there were no solution with all the constraints, so the solver relaxed a
constraint (“CompositeRoot -|>- Component”) and find one solution. This solution has a weight
of 60, because the solver relaxed a constraint of weight 60.
SEE ALSO FRAMEWORK DOCUMENTATION (cf. Tom Tourwe’s PhD thesis)
16
16/18
Explanation-based constraint
programming (4/4)
Advantages:
– Complete forms of patterns
– Constraint systems directly from patterns
– Explanations on relaxed constraints
Drawbacks:
– Fine tuning (but less than fuzzy nets! ☺)
– Weights
Advantages:
-Constraint systems describe complete forms. The solver takes care of computing
distorted forms.
-We obtain constraint systems directly from the pattern description.
-We have explanations on the constraints that have been relaxed.
Drawbacks:
-Fine tuning (but less than fuzzy nets! ☺).
-Weights.
17
17/18
Putting it all together
With Ptidej, we can
– Load a program (PDL)
– Load dynamic information (Caffeine)
– Choose a pattern to detect (PDL)
– Load concrete patterns (Ptidej Solver)
Demo?
Finally, we develop a tool, Ptidej (Pattern Trace Identification, Detection, and
Enhancement in Java) that puts all the declarative meta-programming techniques
together.
With Ptidej, we can:
-Load a program and represent its architecture using PDL.
-Load dynamic information related to the program. We obtain the dynamic information
from Caffeine.
-Choose a pattern to detect. We obtain pattern descriptions from PDL (and PatternsBox).
-Detect and load the results. We obtain the results of the detection from Ptidej Solver.
MENTION TRANSFORMATIONS AND REFACTORINGS.
18
18/18
Discussion
Design pattern and design defects
– Meta-modelling
– Meta-logic programming
– Explanation-based constraint programming
Comments? Ideas? Questions?
To conclude, we introduced three declarative meta-programming techniques.
We use each of these meta-programming techniques in a different context.
Each of these techniques has advantages and drawbacks.
Now, I would like to discuss with you these techniques, to have your opinions, to listen
your comments, to answer your questions.
19
19/18
Paper demo: Ptidej (1/4)
20
20/18
Paper demo (2/4)
21
21/18
Paper demo (3/4)
22
22/18
Paper demo (4/4)

More Related Content

What's hot

9781111530532 ppt ch08
9781111530532 ppt ch089781111530532 ppt ch08
9781111530532 ppt ch08Terry Yoast
 
9781111530532 ppt ch05
9781111530532 ppt ch059781111530532 ppt ch05
9781111530532 ppt ch05Terry Yoast
 
9781111530532 ppt ch13
9781111530532 ppt ch139781111530532 ppt ch13
9781111530532 ppt ch13Terry Yoast
 
Chapter 2 - Basic Elements of Java
Chapter 2 - Basic Elements of JavaChapter 2 - Basic Elements of Java
Chapter 2 - Basic Elements of JavaAdan Hubahib
 
9781111530532 ppt ch03
9781111530532 ppt ch039781111530532 ppt ch03
9781111530532 ppt ch03Terry Yoast
 
Basics of reflection
Basics of reflectionBasics of reflection
Basics of reflectionkim.mens
 
9781111530532 ppt ch06
9781111530532 ppt ch069781111530532 ppt ch06
9781111530532 ppt ch06Terry Yoast
 
9781111530532 ppt ch04
9781111530532 ppt ch049781111530532 ppt ch04
9781111530532 ppt ch04Terry Yoast
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in javakim.mens
 
9781111530532 ppt ch07
9781111530532 ppt ch079781111530532 ppt ch07
9781111530532 ppt ch07Terry Yoast
 

What's hot (15)

9781111530532 ppt ch08
9781111530532 ppt ch089781111530532 ppt ch08
9781111530532 ppt ch08
 
Chap04
Chap04Chap04
Chap04
 
Pptchapter04
Pptchapter04Pptchapter04
Pptchapter04
 
9781111530532 ppt ch05
9781111530532 ppt ch059781111530532 ppt ch05
9781111530532 ppt ch05
 
9781111530532 ppt ch13
9781111530532 ppt ch139781111530532 ppt ch13
9781111530532 ppt ch13
 
Ppt chapter02
Ppt chapter02Ppt chapter02
Ppt chapter02
 
Chapter 2 - Basic Elements of Java
Chapter 2 - Basic Elements of JavaChapter 2 - Basic Elements of Java
Chapter 2 - Basic Elements of Java
 
9781111530532 ppt ch03
9781111530532 ppt ch039781111530532 ppt ch03
9781111530532 ppt ch03
 
Ppt chapter12
Ppt chapter12Ppt chapter12
Ppt chapter12
 
Basics of reflection
Basics of reflectionBasics of reflection
Basics of reflection
 
9781111530532 ppt ch06
9781111530532 ppt ch069781111530532 ppt ch06
9781111530532 ppt ch06
 
9781111530532 ppt ch04
9781111530532 ppt ch049781111530532 ppt ch04
9781111530532 ppt ch04
 
Ppt chapter11
Ppt chapter11Ppt chapter11
Ppt chapter11
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in java
 
9781111530532 ppt ch07
9781111530532 ppt ch079781111530532 ppt ch07
9781111530532 ppt ch07
 

Similar to Ase02 dmp.ppt

Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using ReflectionGanesh Samarthyam
 
SADP PPTs of all modules - Shanthi D.L.pdf
SADP PPTs of all modules - Shanthi D.L.pdfSADP PPTs of all modules - Shanthi D.L.pdf
SADP PPTs of all modules - Shanthi D.L.pdfB.T.L.I.T
 
Software development effort reduction with Co-op
Software development effort reduction with Co-opSoftware development effort reduction with Co-op
Software development effort reduction with Co-oplbergmans
 
Introduction To Design Patterns
Introduction To Design PatternsIntroduction To Design Patterns
Introduction To Design Patternssukumarraju6
 
Rejunevating software reengineering processes
Rejunevating software reengineering processesRejunevating software reengineering processes
Rejunevating software reengineering processesmanishthaper
 
CSCI-UA 102 sec 3,5, Fall 2015Programming Project 6Joann.docx
CSCI-UA 102 sec 3,5, Fall 2015Programming Project 6Joann.docxCSCI-UA 102 sec 3,5, Fall 2015Programming Project 6Joann.docx
CSCI-UA 102 sec 3,5, Fall 2015Programming Project 6Joann.docxfaithxdunce63732
 
An introduction to the MDA
An introduction to the MDAAn introduction to the MDA
An introduction to the MDALai Ha
 
MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)Jordi Cabot
 
Scala for Machine Learning
Scala for Machine LearningScala for Machine Learning
Scala for Machine LearningPatrick Nicolas
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller ColumnsJonathan Fine
 
Patterns in Python
Patterns in PythonPatterns in Python
Patterns in Pythondn
 
A Taxonomy for Program Metamodels in Program Reverse Engineering
A Taxonomy for Program Metamodels in Program Reverse EngineeringA Taxonomy for Program Metamodels in Program Reverse Engineering
A Taxonomy for Program Metamodels in Program Reverse EngineeringHironori Washizaki
 
Introduction to Model-Based Machine Learning
Introduction to Model-Based Machine LearningIntroduction to Model-Based Machine Learning
Introduction to Model-Based Machine LearningDaniel Emaasit
 

Similar to Ase02 dmp.ppt (20)

ASE02 DMP.ppt
ASE02 DMP.pptASE02 DMP.ppt
ASE02 DMP.ppt
 
010821+presentation+oti.ppt
010821+presentation+oti.ppt010821+presentation+oti.ppt
010821+presentation+oti.ppt
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using Reflection
 
UNIT1-JAVA.pptx
UNIT1-JAVA.pptxUNIT1-JAVA.pptx
UNIT1-JAVA.pptx
 
SADP PPTs of all modules - Shanthi D.L.pdf
SADP PPTs of all modules - Shanthi D.L.pdfSADP PPTs of all modules - Shanthi D.L.pdf
SADP PPTs of all modules - Shanthi D.L.pdf
 
Software development effort reduction with Co-op
Software development effort reduction with Co-opSoftware development effort reduction with Co-op
Software development effort reduction with Co-op
 
Introduction To Design Patterns
Introduction To Design PatternsIntroduction To Design Patterns
Introduction To Design Patterns
 
Rejunevating software reengineering processes
Rejunevating software reengineering processesRejunevating software reengineering processes
Rejunevating software reengineering processes
 
CSCI-UA 102 sec 3,5, Fall 2015Programming Project 6Joann.docx
CSCI-UA 102 sec 3,5, Fall 2015Programming Project 6Joann.docxCSCI-UA 102 sec 3,5, Fall 2015Programming Project 6Joann.docx
CSCI-UA 102 sec 3,5, Fall 2015Programming Project 6Joann.docx
 
An introduction to the MDA
An introduction to the MDAAn introduction to the MDA
An introduction to the MDA
 
MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)
 
OOPJ.pptx
OOPJ.pptxOOPJ.pptx
OOPJ.pptx
 
Scala for Machine Learning
Scala for Machine LearningScala for Machine Learning
Scala for Machine Learning
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
ALT
ALTALT
ALT
 
Patterns in Python
Patterns in PythonPatterns in Python
Patterns in Python
 
A Taxonomy for Program Metamodels in Program Reverse Engineering
A Taxonomy for Program Metamodels in Program Reverse EngineeringA Taxonomy for Program Metamodels in Program Reverse Engineering
A Taxonomy for Program Metamodels in Program Reverse Engineering
 
Introduction to Model-Based Machine Learning
Introduction to Model-Based Machine LearningIntroduction to Model-Based Machine Learning
Introduction to Model-Based Machine Learning
 
Ase02.ppt
Ase02.pptAse02.ppt
Ase02.ppt
 
Ooad unit 1
Ooad unit 1Ooad unit 1
Ooad unit 1
 

More from Yann-Gaël Guéhéneuc

Advice for writing a NSERC Discovery grant application v0.5
Advice for writing a NSERC Discovery grant application v0.5Advice for writing a NSERC Discovery grant application v0.5
Advice for writing a NSERC Discovery grant application v0.5Yann-Gaël Guéhéneuc
 
Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1Yann-Gaël Guéhéneuc
 
Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22Yann-Gaël Guéhéneuc
 
Consequences and Principles of Software Quality v0.3
Consequences and Principles of Software Quality v0.3Consequences and Principles of Software Quality v0.3
Consequences and Principles of Software Quality v0.3Yann-Gaël Guéhéneuc
 
Some Pitfalls with Python and Their Possible Solutions v0.9
Some Pitfalls with Python and Their Possible Solutions v0.9Some Pitfalls with Python and Their Possible Solutions v0.9
Some Pitfalls with Python and Their Possible Solutions v0.9Yann-Gaël Guéhéneuc
 
An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...
An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...
An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...Yann-Gaël Guéhéneuc
 
An Explanation of the Halting Problem and Its Consequences
An Explanation of the Halting Problem and Its ConsequencesAn Explanation of the Halting Problem and Its Consequences
An Explanation of the Halting Problem and Its ConsequencesYann-Gaël Guéhéneuc
 
Informaticien(ne)s célèbres (v1.0.2, 19/02/20)
Informaticien(ne)s célèbres (v1.0.2, 19/02/20)Informaticien(ne)s célèbres (v1.0.2, 19/02/20)
Informaticien(ne)s célèbres (v1.0.2, 19/02/20)Yann-Gaël Guéhéneuc
 
On Java Generics, History, Use, Caveats v1.1
On Java Generics, History, Use, Caveats v1.1On Java Generics, History, Use, Caveats v1.1
On Java Generics, History, Use, Caveats v1.1Yann-Gaël Guéhéneuc
 
On Reflection in OO Programming Languages v1.6
On Reflection in OO Programming Languages v1.6On Reflection in OO Programming Languages v1.6
On Reflection in OO Programming Languages v1.6Yann-Gaël Guéhéneuc
 

More from Yann-Gaël Guéhéneuc (20)

Advice for writing a NSERC Discovery grant application v0.5
Advice for writing a NSERC Discovery grant application v0.5Advice for writing a NSERC Discovery grant application v0.5
Advice for writing a NSERC Discovery grant application v0.5
 
Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1
 
Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22
 
Consequences and Principles of Software Quality v0.3
Consequences and Principles of Software Quality v0.3Consequences and Principles of Software Quality v0.3
Consequences and Principles of Software Quality v0.3
 
Some Pitfalls with Python and Their Possible Solutions v0.9
Some Pitfalls with Python and Their Possible Solutions v0.9Some Pitfalls with Python and Their Possible Solutions v0.9
Some Pitfalls with Python and Their Possible Solutions v0.9
 
An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...
An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...
An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...
 
An Explanation of the Halting Problem and Its Consequences
An Explanation of the Halting Problem and Its ConsequencesAn Explanation of the Halting Problem and Its Consequences
An Explanation of the Halting Problem and Its Consequences
 
Are CPUs VMs Like Any Others? v1.0
Are CPUs VMs Like Any Others? v1.0Are CPUs VMs Like Any Others? v1.0
Are CPUs VMs Like Any Others? v1.0
 
Informaticien(ne)s célèbres (v1.0.2, 19/02/20)
Informaticien(ne)s célèbres (v1.0.2, 19/02/20)Informaticien(ne)s célèbres (v1.0.2, 19/02/20)
Informaticien(ne)s célèbres (v1.0.2, 19/02/20)
 
Well-known Computer Scientists v1.0.2
Well-known Computer Scientists v1.0.2Well-known Computer Scientists v1.0.2
Well-known Computer Scientists v1.0.2
 
On Java Generics, History, Use, Caveats v1.1
On Java Generics, History, Use, Caveats v1.1On Java Generics, History, Use, Caveats v1.1
On Java Generics, History, Use, Caveats v1.1
 
On Reflection in OO Programming Languages v1.6
On Reflection in OO Programming Languages v1.6On Reflection in OO Programming Languages v1.6
On Reflection in OO Programming Languages v1.6
 
ICSOC'21
ICSOC'21ICSOC'21
ICSOC'21
 
Vissoft21.ppt
Vissoft21.pptVissoft21.ppt
Vissoft21.ppt
 
Service computation20.ppt
Service computation20.pptService computation20.ppt
Service computation20.ppt
 
Serp4 iot20.ppt
Serp4 iot20.pptSerp4 iot20.ppt
Serp4 iot20.ppt
 
Msr20.ppt
Msr20.pptMsr20.ppt
Msr20.ppt
 
Iwesep19.ppt
Iwesep19.pptIwesep19.ppt
Iwesep19.ppt
 
Icsoc20.ppt
Icsoc20.pptIcsoc20.ppt
Icsoc20.ppt
 
Icsoc18.ppt
Icsoc18.pptIcsoc18.ppt
Icsoc18.ppt
 

Recently uploaded

Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 

Recently uploaded (20)

Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 

Ase02 dmp.ppt

  • 1. 1 Three musketeers to the rescue Meta-modelling, Logic Programming, and Explanation-based Constraint Programming for Pattern Description and Detection Yann-Gaël Guéhéneuc guehene@emn.fr Object Technology International, Inc., Canada École des Mines de Nantes, France Hello, my name is … from the École des Mines de Nantes. My work is partly funded by OTI. Today, I present three distinct meta-declarative programming techniques we develop and use for our research on patterns. This presentation has been given at the ASE 2002 workshop on Declarative Meta-Programming
  • 2. 2 2/18 The musketeers were French… Do not hesitate to interrupt! Questions are most welcome! Well, as the Three Musketeers, I am also French. My accent might be a bit of a problem… Do not hesitate to interrupt me and to ask questions!
  • 3. 3 3/18 Objectives of this presentation Present our use of three declarative meta-programming techniques – Meta-modelling – Meta-logic programming – Explanation-based constraint programming Context, example, advantages/drawbacks Discuss these techniques, their limitations, their use in other contexts In our research, we use three declarative meta-programming techniques : -Meta-modelling. -Meta-logic programming. -Explanation-based constraint programming. We use these techniques for the description, application, and detection of design patterns and design defects. First, I introduce the context of our research. Then, I present each of these declarative meta-programming techniques. I also give an example and the reasons why it is a declarative meta-programming technique. I also discuss some of its advantages and drawbacks. Finally, I wish to discuss with you these techniques, their limitations, other better techniques, other possible applications…
  • 4. 4 4/18 Context of our research Design patterns ⇒ Design defects ⇒ Patterns Patterns description Pattern application (design patterns only! ☺) Pattern detection We work on design patterns and design defects. Design patterns are “descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context” ([Gamma, 1994], page 3). Design patterns describe a problem, a solution, and the consequences when applying the solutions. The solution of a design pattern is generally represented with OMT diagrams and source code examples; That is the solution of a design pattern is generally represented with a micro-architecture exemplifying the solution. We argue that: -Design defects are similar to design patterns and we can represent them as design patterns. -A micro-architecture close but not identical to the solution of a design pattern represent a possible design defects. We call design patterns and design defect “patterns”. We want to describe patterns (the micro-architectures representing the solutions of design patterns, or representing design defects). We want to apply design patterns from descriptions of design patterns. We want to detect complete forms of design patterns, distorted forms of design patterns, and design defects.
  • 5. 5 5/18 Meta-modelling (1/4) Pattern Description Language (PDL): – A meta-model – Abstract models of patterns An abstract model is a first class entity: – We can parameterize it (PatternsBox) – It can generate its corresponding code – It can detect complete micro-architectures that are similar to itself We develop Pattern Description Language (PDL), a meta-model to describe abstract models of patterns. An abstract model is declared using constituents of PDL. An abstract model represents the micro-architecture solution of a pattern. We can parameterize an abstract model to obtain a concrete model of a pattern, using for example PatternsBox. We can ask an abstract model (or a concrete model) to generate itself, for example as Java source code, as constraint system, or as an input for other tools. We can ask an abstract model to detect itself in a given Java program architecture (source code/class files). When an abstract model detects itself, we obtain concrete models of the pattern.
  • 6. 6 6/18 Meta-modelling (2/4) Translates into Informal descriptions from [Gamma, 1994] Instance of Interface Instance of Class Instance of Association Instance of Delegation name() Instance of Method Instance of Pattern Here is a simple example of an abstract model. This abstract model describes the Composite design pattern. We describe the micro-architecture solution advocated by the Composite design pattern and the informal information using constituents of the meta-model.
  • 7. 7 7/18 Meta-modelling (3/4) public Composite() throws CloneNotSupportedException, PatternDeclarationException { super(); final Class aClass; final Interface anInterface; final DelegatingMethod aDelegatingMethod; final Method abMethod; // Interface Component. anInterface = new Interface("Component"); this.addEntity(anInterface); abMethod = new Method("Operation"); anInterface.addElement(abMethod); // Association children. final Composition aComposition = new Composition("children", anInterface, 2); // Class Composite. aClass = new Class("Composite"); this.addEntity(aClass); aClass.addImplementedEntity(anInterface); aClass.addElement(aComposition); aDelegatingMethod = new DelegatingMethod( "Operation", aComposition); aDelegatingMethod.attachTo(abMethod); aClass.addElement(aDelegatingMethod); // Class Leaf. this.addLeaf(new String[] { "Leaf" }); } Here is the source code describing the Composite design pattern. It is declarative because each abstract model is declared by a sequence of statements. It is meta because the statements are instances of constituents of the meta-model. It is programming because we use the abstract model programmatically to reason about the design pattern solution.
  • 8. 8 8/18 Meta-modelling (4/4) Advantages: – Patterns are first-class entities – Patterns embody all the logic Drawbacks: – The meta-model only describes one perspective on patterns Advantages: -Patterns are first-class entities. -Patterns descriptions embody all the logic related to patterns (application, detection). Drawbacks: -The meta-model only describes one perspective on patterns. For example, PDL only describes the structure of patterns (and some behavioural information).
  • 9. 9 9/18 Meta-logic programming (1/4) Caffeine is a program for trace analysis of Java programs Caffeine is based on: – A model of trace – A model of execution events that abstracts the program execution – The JPDA – A Prolog engine (JIProlog) Caffeine is a tool for the analysis of Java programs. It defines a model of trace: A trace is a history of execution events. It defines a model of execution events: Execution events are emitted by the program being analyzed and abstract the program behaviour. It is a program that runs as a co-routine of a program to analyze. It drives the program being analyzed using the JPDA (Java Platform Debug Architecture). It receives events from the program being analyzed as Prolog predicates and can reflect on these events.
  • 10. 10 10/18 Meta-logic programming (2/4) class A { String s; A(String s) { … } String foo() { … return "Happy" + s; } protected void finalize() { … } } classLoad + classUnload programEnd fieldAccess fieldModification constructorEntry constructorExit methodEntry methodExit finalizerEntry finalizerExit Here is the list of execution events that can be emitted by the program being analyzed. All these execution events might not be of interest, so we can filter out the events we are not interested in. Filtering out events improves slightly the performances of the program being analyzed.
  • 11. 11 11/18 Meta-logic programming (3/4) nextPlaceNextQueen :- nextMethodEntryEvent(N), isPlaceNextQueen(N). isPlaceNextQueen(placeNextQueen) :- !. isPlaceNextQueen(removeQueen) :- !, fail. isPlaceNextQueen(setQueen) :- !, fail. isPlaceNextQueen(_) :- nextPlaceNextQueen. query(N, M) :- % I go to the next % setQueen(...) % placeNextQueen(...) % removeQueen(...) % triplet of events: nextMethodEntryEvent(setQueen), nextPlaceNextQueen, nextMethodEntryEvent(removeQueen), % I count the number of time I execute the query: !, N1 is N + 1, query(N1, M). query(N, N). Here is the source code counting the number of times the program being analyzed performs a sequence of method invocations. It is declarative because the analysis is declared by a sequence of predicates. It is meta because the predicates abstract the execution of the program being analyzed. It is programming because we use this analysis programmatically to reason about the program execution. LINK WITH SOUL (http://prog.vub.ac.be/research/DMP/soul/soul2.html)
  • 12. 12 12/18 Meta-logic programming (4/4) Advantages: – Powerful Drawbacks: – No universal quantifiers – No temporal relationships – Performances Advantages: -Powerful and natural expressions of queries. Drawbacks: -No universal quantifiers. -No temporal relationships. -Performances.
  • 13. 13 13/18 Explanation-based constraint programming (1/4) Abstract models of design defects ONE Assumption: – Micro-architectures similar but not identical to design pattern solutions might be: • Distorted because clumsily implemented • Distorted because not fit • Something else, sorry! ☺ An explanation-based constraint solver: Ptidej Solver (PaLM) Using PDL, we describe abstract model of design defects. We also make one assumption: Micro-architectures that are similar but not identical to design pattern solutions are: -Either distorted design patterns because the design patterns are clumsily implemented. -Or distorted design patterns because the design patterns do not fit in the architecture. -Or something else, but it is still worth to know that it looked like some design pattern! So, we want to detect distorted micro-architectures in a given program architecture. We use explanation-based constraint programming. Explanation-based constraint programming is basically constraint programming, except that when there is no more solutions (i.e., a contradiction), the solver knows why: It knows the constraints that led to the contradiction. We can remove from the constraint systems the constraints leading to the contradiction and obtain more distorted solutions to the problem. We develop an explanation-based constraint solver: Ptidej Solver. Ptidej Solver is based on the PaLM explanation-based constraint solver, PaLM is the reference implementation regarding explanation-based constraint programming.
  • 14. 14 14/18 Explanation-based constraint programming (2/4) [ac4ProblemForCompositePattern() : PtidejProblem -> let pb := makePtidejProblem("Composite Pattern Problem", length(listOfEntities), 90), compositeRoot := makePtidejIntVar(pb, "CompositeRoot", 1, length(listOfEntities)), component := makePtidejIntVar(pb, "Component", 1, length(listOfEntities)), composite := makePtidejIntVar(pb, "Composite", 1, length(listOfEntities), false), leaf := makePtidejIntVar(pb, "Leaf", 1, length(listOfEntities), false) in ( post(pb, makeCompositionAC4Constraint("CompositeRoot <>--> Component", "...", compositeRoot, component), 90), post(pb, makeInheritanceAC4Constraint("CompositeRoot -|>- Component", "...", compositeRoot, component), 60), post(pb, makeInheritanceAC4Constraint("Composite -|>- CompositeRoot", "...", composite, compositeRoot), 90), post(pb, makeInheritancePathAC4Constraint("Leaf -|>- ... -|>- Component", "", leaf, component), 90), post(pb, makeIgnoranceAC4Constraint("Component -/--> Leaf", "...", component, leaf), 10), post(pb, makeIgnoranceAC4Constraint("Leaf -/--> Composite", "...", leaf, composite), 30), post(pb, makeNotEqualAC4Constraint("Component <> Leaf", "...", component, leaf), 100), post(pb, makeNotEqualAC4Constraint("Composite <> Leaf", "...", composite, leaf), 100), post(pb, makeNotEqualAC4Constraint("CompositeRoot <> Leaf", "...", compositeRoot, leaf), 100), pb ) ] Here is an example of the constraint system we use to detect complete and distorted micro-architecture identical or similar to the Composite design pattern. This constraint system is directly obtained from the abstract model of the Composite design pattern. First, we declare the problem. Then, we declare the different variables. Each variable represents an actor in the pattern. In particular, the Composite and Leaf actor are declared as not enumerated, because their roles may be filled by more than one entity in the software architecture. Finally, we post the different constraints representing the Composite design pattern. We associate a weight with each constraint to tell the Ptidej Solver which constraints it can relax and which it can not. It is declarative because the constraint system is declared by a sequence of constraints. It is meta because the constraints apply on the architecture of the program. It is programming because we use constraint systems programmatically to detect complete and distorted forms of design patterns.
  • 15. 15 15/18 Explanation-based constraint programming (3/4) # Solution without constraint: # -|>- : CompositeRoot -|>- Component 1.60.XCommand = Composite, Component |ntttjavaXL.XClass c1, javaXL.XClass c2 |ntttc1.setSuperclass(c2.getName()); 1.60.CompositeRoot = jtu.example.composite2.Document 1.60.Component = jtu.example.composite2.Element 1.60.Composite = jtu.example.composite2.Document 1.60.Leaf-1 = jtu.example.composite2.IndentedParagraph 1.60.Leaf-2 = jtu.example.composite2.Paragraph 1.60.Leaf-3 = jtu.example.composite2.Title # Solved in 0min (130ms). Here is some results from a simple text editor. The solver computed first the solutions with all the constraints. It appeared that there were no solution with all the constraints, so the solver relaxed a constraint (“CompositeRoot -|>- Component”) and find one solution. This solution has a weight of 60, because the solver relaxed a constraint of weight 60. SEE ALSO FRAMEWORK DOCUMENTATION (cf. Tom Tourwe’s PhD thesis)
  • 16. 16 16/18 Explanation-based constraint programming (4/4) Advantages: – Complete forms of patterns – Constraint systems directly from patterns – Explanations on relaxed constraints Drawbacks: – Fine tuning (but less than fuzzy nets! ☺) – Weights Advantages: -Constraint systems describe complete forms. The solver takes care of computing distorted forms. -We obtain constraint systems directly from the pattern description. -We have explanations on the constraints that have been relaxed. Drawbacks: -Fine tuning (but less than fuzzy nets! ☺). -Weights.
  • 17. 17 17/18 Putting it all together With Ptidej, we can – Load a program (PDL) – Load dynamic information (Caffeine) – Choose a pattern to detect (PDL) – Load concrete patterns (Ptidej Solver) Demo? Finally, we develop a tool, Ptidej (Pattern Trace Identification, Detection, and Enhancement in Java) that puts all the declarative meta-programming techniques together. With Ptidej, we can: -Load a program and represent its architecture using PDL. -Load dynamic information related to the program. We obtain the dynamic information from Caffeine. -Choose a pattern to detect. We obtain pattern descriptions from PDL (and PatternsBox). -Detect and load the results. We obtain the results of the detection from Ptidej Solver. MENTION TRANSFORMATIONS AND REFACTORINGS.
  • 18. 18 18/18 Discussion Design pattern and design defects – Meta-modelling – Meta-logic programming – Explanation-based constraint programming Comments? Ideas? Questions? To conclude, we introduced three declarative meta-programming techniques. We use each of these meta-programming techniques in a different context. Each of these techniques has advantages and drawbacks. Now, I would like to discuss with you these techniques, to have your opinions, to listen your comments, to answer your questions.