SlideShare a Scribd company logo
1 of 22
Download to read offline
This presentation has been given at the ASE 2002 workshop on Declarative Meta-Programming




                         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

                       École des Mines                                                      Object Technology
                       de Nantes, France                                                    International, Inc., Canada




          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.




                                                                                                                          1
The musketeers were French…

                 Do not hesitate to
                 interrupt!
                 Questions are most
                 welcome!




      2/18




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!




                                                        2
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
       3/18
                   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…




                                                                                             3
Context of our research

                  Design patterns
                    ⇒ Design defects
                    ⇒ Patterns

                  Patterns description
                  Pattern application
                       (design patterns only! ☺)
      4/18        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.

                                                                                              4
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
      5/18




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.




                                                                                           5
Meta-modelling                                            (2/4)
                                                              Informal descriptions
                                                              from [Gamma, 1994]




                             Translates into                  Instance of Pattern

                                                              Instance of Interface

                                                              Instance of Class

                                                              Instance of Association

                                                              Instance of Delegation
      6/18                                             name() Instance of Method




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.




                                                                                        6
Meta-modelling                                                                        (3/4)
              public Composite() throws
                   CloneNotSupportedException,
                   PatternDeclarationException {
                    super();

                    final Class aClass;
                    final Interface anInterface;
                    final DelegatingMethod aDelegatingMethod;
                    final Method abMethod;

                    // Interface Component.                            // Class Composite.
                    anInterface = new Interface("Component");          aClass = new Class("Composite");
                    this.addEntity(anInterface);                       this.addEntity(aClass);
                    abMethod = new Method("Operation");                aClass.addImplementedEntity(anInterface);
                    anInterface.addElement(abMethod);                  aClass.addElement(aComposition);
                                                                       aDelegatingMethod = new DelegatingMethod(
                    // Association children.                                "Operation",
                    final Composition aComposition =                        aComposition);
                    new Composition("children", anInterface, 2);       aDelegatingMethod.attachTo(abMethod);
                                                                       aClass.addElement(aDelegatingMethod);

                                                                       // Class Leaf.
      7/18                                                             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.




                                                                                                                   7
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

       8/18




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).




                                                                                            8
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)
      9/18




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.




                                                                                          9
Meta-logic programming                                       (2/4)
              class A {                          fieldAccess
                   String s;                     fieldModification
                   A(String s) {
                        …                        constructorEntry
                   }
                   String foo() {
                                                 constructorExit
                        …
                        return "Happy" + s;      methodEntry
                   }
                   protected void finalize() {   methodExit
                        …
                   }
              }                                  finalizerEntry
                                                 finalizerExit
                                                                        classLoad
                                                                      + classUnload
      10/18
                                                                        programEnd


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.




                                                                                              10
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).
      11/18




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)




                                                                                          11
Meta-logic programming             (4/4)

                  Advantages:
                   – Powerful


                  Drawbacks:
                   – No universal quantifiers
                   – No temporal relationships
                   – Performances

      12/18




Advantages:
-Powerful and natural expressions of queries.


Drawbacks:
-No universal quantifiers.
-No temporal relationships.
-Performances.




                                                         12
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:
      13/18
                  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.




                                                                                                13
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
                  )
      14/18   ]




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.




                                                                                                                                      14
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).
      15/18




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)




                                                                                                15
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
      16/18




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.




                                                                                  16
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?

      17/18




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.




                                                                                           17
Discussion

                 Design pattern and design defects
                  – Meta-modelling
                  – Meta-logic programming
                  – Explanation-based constraint programming


                 Comments? Ideas? Questions?


      18/18




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.




                                                                                           18
Paper demo: Ptidej   (1/4)




19/18




                                     19
Paper demo   (2/4)




20/18




                             20
Paper demo   (3/4)




21/18




                             21
Paper demo   (4/4)




22/18




                             22

More Related Content

What's hot

OOP in C#
OOP in C#OOP in C#
OOP in C#DevMix
 
GOF Design pattern with java
GOF Design pattern with javaGOF Design pattern with java
GOF Design pattern with javaRajiv Gupta
 
Learning and imitation in heterogeneous robot groups
Learning and imitation in heterogeneous robot groupsLearning and imitation in heterogeneous robot groups
Learning and imitation in heterogeneous robot groupsWilli Richert
 
Abstract classes and Methods in java
Abstract classes and Methods in javaAbstract classes and Methods in java
Abstract classes and Methods in javaHarish Gyanani
 
IRT Modelling SJTs
IRT Modelling SJTsIRT Modelling SJTs
IRT Modelling SJTsTony Li
 
MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...
MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...
MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...Aravind NC
 
Ireland
IrelandIreland
Irelandanesah
 
Oops presentation java
Oops presentation javaOops presentation java
Oops presentation javaJayasankarPR2
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented Programmingmukhtarhudaya
 
Conceptual Interoperability and Biomedical Data
Conceptual Interoperability and Biomedical DataConceptual Interoperability and Biomedical Data
Conceptual Interoperability and Biomedical DataJim McCusker
 
4.class diagramsusinguml
4.class diagramsusinguml4.class diagramsusinguml
4.class diagramsusingumlAPU
 
Design Patterns
Design PatternsDesign Patterns
Design Patternsppd1961
 
Ch 9-1.Machine Learning: Symbol-based
Ch 9-1.Machine Learning: Symbol-basedCh 9-1.Machine Learning: Symbol-based
Ch 9-1.Machine Learning: Symbol-basedbutest
 

What's hot (20)

Maude primer
Maude primerMaude primer
Maude primer
 
OOP in C#
OOP in C#OOP in C#
OOP in C#
 
GOF Design pattern with java
GOF Design pattern with javaGOF Design pattern with java
GOF Design pattern with java
 
Learning and imitation in heterogeneous robot groups
Learning and imitation in heterogeneous robot groupsLearning and imitation in heterogeneous robot groups
Learning and imitation in heterogeneous robot groups
 
7494608
74946087494608
7494608
 
Total oop in c# dot net
Total oop in c# dot netTotal oop in c# dot net
Total oop in c# dot net
 
Abstract classes and Methods in java
Abstract classes and Methods in javaAbstract classes and Methods in java
Abstract classes and Methods in java
 
IRT Modelling SJTs
IRT Modelling SJTsIRT Modelling SJTs
IRT Modelling SJTs
 
MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...
MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...
MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...
 
Ireland
IrelandIreland
Ireland
 
Oops presentation java
Oops presentation javaOops presentation java
Oops presentation java
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented Programming
 
Conceptual Interoperability and Biomedical Data
Conceptual Interoperability and Biomedical DataConceptual Interoperability and Biomedical Data
Conceptual Interoperability and Biomedical Data
 
Ai inductive bias and knowledge
Ai inductive bias and knowledgeAi inductive bias and knowledge
Ai inductive bias and knowledge
 
OO & UML
OO & UMLOO & UML
OO & UML
 
uml
umluml
uml
 
4.class diagramsusinguml
4.class diagramsusinguml4.class diagramsusinguml
4.class diagramsusinguml
 
5
55
5
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Ch 9-1.Machine Learning: Symbol-based
Ch 9-1.Machine Learning: Symbol-basedCh 9-1.Machine Learning: Symbol-based
Ch 9-1.Machine Learning: Symbol-based
 

Similar to ASE02 DMP.ppt

ECOOP01 PhDOOS.ppt
ECOOP01 PhDOOS.pptECOOP01 PhDOOS.ppt
ECOOP01 PhDOOS.pptPtidej Team
 
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
 
Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++Anil Bapat
 
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
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applicationsChandra Sekhar Saripaka
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010Rich Helton
 
Model versioning in context of living
Model versioning in context of livingModel versioning in context of living
Model versioning in context of livingijseajournal
 
7 latest-dot-net-interview-questions
7  latest-dot-net-interview-questions7  latest-dot-net-interview-questions
7 latest-dot-net-interview-questionssadiqkhanpathan
 
모듈형 패키지를 활용한 나만의 기계학습 모형 만들기 - 회귀나무모형을 중심으로
모듈형 패키지를 활용한 나만의 기계학습 모형 만들기 - 회귀나무모형을 중심으로 모듈형 패키지를 활용한 나만의 기계학습 모형 만들기 - 회귀나무모형을 중심으로
모듈형 패키지를 활용한 나만의 기계학습 모형 만들기 - 회귀나무모형을 중심으로 r-kor
 
An Introduction to the Jena API
An Introduction to the Jena APIAn Introduction to the Jena API
An Introduction to the Jena APICraig Trim
 
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
 
Monte -- machine learning in Python
Monte -- machine learning in PythonMonte -- machine learning in Python
Monte -- machine learning in Pythonbutest
 
Monte -- machine learning in Python
Monte -- machine learning in PythonMonte -- machine learning in Python
Monte -- machine learning in Pythonbutest
 
Evolution of Patterns
Evolution of PatternsEvolution of Patterns
Evolution of PatternsChris Eargle
 

Similar to ASE02 DMP.ppt (20)

Ase02 dmp.ppt
Ase02 dmp.pptAse02 dmp.ppt
Ase02 dmp.ppt
 
ECOOP01 PhDOOS.ppt
ECOOP01 PhDOOS.pptECOOP01 PhDOOS.ppt
ECOOP01 PhDOOS.ppt
 
Utility Classes
Utility ClassesUtility Classes
Utility Classes
 
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)
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++
 
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
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applications
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010
 
Model versioning in context of living
Model versioning in context of livingModel versioning in context of living
Model versioning in context of living
 
Patterns Overview
Patterns OverviewPatterns Overview
Patterns Overview
 
7 latest-dot-net-interview-questions
7  latest-dot-net-interview-questions7  latest-dot-net-interview-questions
7 latest-dot-net-interview-questions
 
모듈형 패키지를 활용한 나만의 기계학습 모형 만들기 - 회귀나무모형을 중심으로
모듈형 패키지를 활용한 나만의 기계학습 모형 만들기 - 회귀나무모형을 중심으로 모듈형 패키지를 활용한 나만의 기계학습 모형 만들기 - 회귀나무모형을 중심으로
모듈형 패키지를 활용한 나만의 기계학습 모형 만들기 - 회귀나무모형을 중심으로
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
An Introduction to the Jena API
An Introduction to the Jena APIAn Introduction to the Jena API
An Introduction to the Jena API
 
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
 
Monte -- machine learning in Python
Monte -- machine learning in PythonMonte -- machine learning in Python
Monte -- machine learning in Python
 
Monte -- machine learning in Python
Monte -- machine learning in PythonMonte -- machine learning in Python
Monte -- machine learning in Python
 
Evolution of Patterns
Evolution of PatternsEvolution of Patterns
Evolution of Patterns
 

More from Ptidej Team

From IoT to Software Miniaturisation
From IoT to Software MiniaturisationFrom IoT to Software Miniaturisation
From IoT to Software MiniaturisationPtidej Team
 
Presentation by Lionel Briand
Presentation by Lionel BriandPresentation by Lionel Briand
Presentation by Lionel BriandPtidej Team
 
Manel Abdellatif
Manel AbdellatifManel Abdellatif
Manel AbdellatifPtidej Team
 
Azadeh Kermansaravi
Azadeh KermansaraviAzadeh Kermansaravi
Azadeh KermansaraviPtidej Team
 
CSED - Manel Grichi
CSED - Manel GrichiCSED - Manel Grichi
CSED - Manel GrichiPtidej Team
 
Cristiano Politowski
Cristiano PolitowskiCristiano Politowski
Cristiano PolitowskiPtidej Team
 
Will io t trigger the next software crisis
Will io t trigger the next software crisisWill io t trigger the next software crisis
Will io t trigger the next software crisisPtidej Team
 
Thesis+of+laleh+eshkevari.ppt
Thesis+of+laleh+eshkevari.pptThesis+of+laleh+eshkevari.ppt
Thesis+of+laleh+eshkevari.pptPtidej Team
 
Thesis+of+nesrine+abdelkafi.ppt
Thesis+of+nesrine+abdelkafi.pptThesis+of+nesrine+abdelkafi.ppt
Thesis+of+nesrine+abdelkafi.pptPtidej Team
 

More from Ptidej Team (20)

From IoT to Software Miniaturisation
From IoT to Software MiniaturisationFrom IoT to Software Miniaturisation
From IoT to Software Miniaturisation
 
Presentation
PresentationPresentation
Presentation
 
Presentation
PresentationPresentation
Presentation
 
Presentation
PresentationPresentation
Presentation
 
Presentation by Lionel Briand
Presentation by Lionel BriandPresentation by Lionel Briand
Presentation by Lionel Briand
 
Manel Abdellatif
Manel AbdellatifManel Abdellatif
Manel Abdellatif
 
Azadeh Kermansaravi
Azadeh KermansaraviAzadeh Kermansaravi
Azadeh Kermansaravi
 
Mouna Abidi
Mouna AbidiMouna Abidi
Mouna Abidi
 
CSED - Manel Grichi
CSED - Manel GrichiCSED - Manel Grichi
CSED - Manel Grichi
 
Cristiano Politowski
Cristiano PolitowskiCristiano Politowski
Cristiano Politowski
 
Will io t trigger the next software crisis
Will io t trigger the next software crisisWill io t trigger the next software crisis
Will io t trigger the next software crisis
 
MIPA
MIPAMIPA
MIPA
 
Thesis+of+laleh+eshkevari.ppt
Thesis+of+laleh+eshkevari.pptThesis+of+laleh+eshkevari.ppt
Thesis+of+laleh+eshkevari.ppt
 
Thesis+of+nesrine+abdelkafi.ppt
Thesis+of+nesrine+abdelkafi.pptThesis+of+nesrine+abdelkafi.ppt
Thesis+of+nesrine+abdelkafi.ppt
 
Medicine15.ppt
Medicine15.pptMedicine15.ppt
Medicine15.ppt
 
Qrs17b.ppt
Qrs17b.pptQrs17b.ppt
Qrs17b.ppt
 
Icpc11c.ppt
Icpc11c.pptIcpc11c.ppt
Icpc11c.ppt
 
Icsme16.ppt
Icsme16.pptIcsme16.ppt
Icsme16.ppt
 
Msr17a.ppt
Msr17a.pptMsr17a.ppt
Msr17a.ppt
 
Icsoc15.ppt
Icsoc15.pptIcsoc15.ppt
Icsoc15.ppt
 

Recently uploaded

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Recently uploaded (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

ASE02 DMP.ppt

  • 1. This presentation has been given at the ASE 2002 workshop on Declarative Meta-Programming 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 École des Mines Object Technology de Nantes, France International, Inc., Canada 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. 1
  • 2. The musketeers were French… Do not hesitate to interrupt! Questions are most welcome! 2/18 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! 2
  • 3. 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 3/18 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… 3
  • 4. Context of our research Design patterns ⇒ Design defects ⇒ Patterns Patterns description Pattern application (design patterns only! ☺) 4/18 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. 4
  • 5. 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 5/18 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. 5
  • 6. Meta-modelling (2/4) Informal descriptions from [Gamma, 1994] Translates into Instance of Pattern Instance of Interface Instance of Class Instance of Association Instance of Delegation 6/18 name() Instance of Method 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. 6
  • 7. Meta-modelling (3/4) public Composite() throws CloneNotSupportedException, PatternDeclarationException { super(); final Class aClass; final Interface anInterface; final DelegatingMethod aDelegatingMethod; final Method abMethod; // Interface Component. // Class Composite. anInterface = new Interface("Component"); aClass = new Class("Composite"); this.addEntity(anInterface); this.addEntity(aClass); abMethod = new Method("Operation"); aClass.addImplementedEntity(anInterface); anInterface.addElement(abMethod); aClass.addElement(aComposition); aDelegatingMethod = new DelegatingMethod( // Association children. "Operation", final Composition aComposition = aComposition); new Composition("children", anInterface, 2); aDelegatingMethod.attachTo(abMethod); aClass.addElement(aDelegatingMethod); // Class Leaf. 7/18 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. 7
  • 8. 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 8/18 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). 8
  • 9. 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) 9/18 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. 9
  • 10. Meta-logic programming (2/4) class A { fieldAccess String s; fieldModification A(String s) { … constructorEntry } String foo() { constructorExit … return "Happy" + s; methodEntry } protected void finalize() { methodExit … } } finalizerEntry finalizerExit classLoad + classUnload 10/18 programEnd 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. 10
  • 11. 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). 11/18 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) 11
  • 12. Meta-logic programming (4/4) Advantages: – Powerful Drawbacks: – No universal quantifiers – No temporal relationships – Performances 12/18 Advantages: -Powerful and natural expressions of queries. Drawbacks: -No universal quantifiers. -No temporal relationships. -Performances. 12
  • 13. 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: 13/18 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. 13
  • 14. 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 ) 14/18 ] 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. 14
  • 15. 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). 15/18 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) 15
  • 16. 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 16/18 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. 16
  • 17. 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? 17/18 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. 17
  • 18. Discussion Design pattern and design defects – Meta-modelling – Meta-logic programming – Explanation-based constraint programming Comments? Ideas? Questions? 18/18 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. 18
  • 19. Paper demo: Ptidej (1/4) 19/18 19
  • 20. Paper demo (2/4) 20/18 20
  • 21. Paper demo (3/4) 21/18 21
  • 22. Paper demo (4/4) 22/18 22