Ptidej in my PaLM

  Using explanations for
design patterns identification
Us
     Æ   Yann-Gaël Guéhéneuc
         n 2nd year PhD student
         n Object Models and Components Team
         n Partly funded by Object Technology International, Inc.
           (Canada)

     Æ   Narendra Jussien
         n Assistant Professor
         n Constraint Programming Team


     Æ   Research hosted by the
         École des Mines de Nantes
Long-term goal

n Toimprove the quality of software
 architecture
  – To improve flexibility, understandability, …
  – Maintenance = 75% of the life of a software
n Design   patterns
  « Describe simple and elegant solutions to specific
    architectural problems in OO software design »
  – Experience of skillful developers
  – Recurrent architectural problems
sic       Composite
A Ba xample :
     E        pattern solution




Composite composes objects into tree structures to
represent part-whole hierarchies. It lets clients treat
individual objects and compositions of objects uniformly.
Main ideas

n Design patterns are good micro-
 architectural solutions

n Micro-architectures
                    close to a design
 pattern solution may be improved

n Theseare transformed into the
 corresponding design pattern solution
Problem

n To   identify
  – The Use of a design pattern solution
       • Well written code
       • Notion of complete version
  – The Misuse of a design pattern solution
       • Code improvement
       • Notion of distorted version
       + No up-front descriptions of the distortions
ic
A Bas xample : Problem
     E
                Complete and
                distorted versions?
Complete and distorted versions

n Related   works
  – The search of sub-graphs in a graph
  – The phase of adaptation in case-based
    reasoning
n But we need complete and distorted
  versions
Æ Explanation-based CP (eCP)
Solution

n Explanation-based       CP enables
  – Justifications
     • Programming = « artistic » activity
     • Explain why / how the code is modified
  – Complete and distorted versions
  – Strong interactivity with the user
     • Dynamic description of the distortions
Explanation-based CP                1/3

n Setof constraints justifying an
 action performed by the solver
  – Value removal
  – Contradiction


n Trace   of the solver behavior
Explanation-based CP            2/3

n Application
  – Assistance upon failure
  – Interactive solvers
  – New search algorithms
    • Path-repair (AAAI 2000)
    • Mac-DBT (CP 2000)
    •…
Explanation-based CP               3/3

n An   implementation: PaLM
  – Developed at the EMN
  – On top of Choco
  – Written in Claire

  – Used in Path-Repair, Mac-DBT
  – Reliable and efficient
Our application

n The   design pattern solution
  – A class defines a variable
  – Relationships among classes define
    constraints
n The   source code of the application
  – The classes define the domain of the
    variables
  – Relationships among classes give the
    semantics of the constraints
ic
A Bas xample : Constraints
     E
n The    Composite design pattern solution




n Its   constraints
            composite < component
            leaf < component
            composite ⊃ component
ic
A Bas xample : Interaction
     E

 composite < component
 leaf < component
 composite ⊃ component
ic
A Bas xample : Results
     E
Our results                                   1/3

n Implementation
  – Constraints
    • Inheritance, creation, composition, …
  – Design pattern solutions
    • Composite, Façade, Factory Method, …
n Experiments
  – Small test-cases
  – JEdit v3.1 (~250 classes), JHotDraw v5.1
    (~155 classes), Ptidej itself (!), …
Our results   2/3
Our results   3/3
Conclusion and future

n An   application of explanation-based CP
  – Non-trivial problem
n Short   term
  – To add more design pattern solutions
  – To develop the constraints system
       • New algorithm CSP-NN [Morning session]
  – Scalability and weights (noise)
n Long    term
  – automation and interaction (usability)

IJCAI01 MSPC.ppt

  • 1.
    Ptidej in myPaLM Using explanations for design patterns identification
  • 2.
    Us Æ Yann-Gaël Guéhéneuc n 2nd year PhD student n Object Models and Components Team n Partly funded by Object Technology International, Inc. (Canada) Æ Narendra Jussien n Assistant Professor n Constraint Programming Team Æ Research hosted by the École des Mines de Nantes
  • 3.
    Long-term goal n Toimprovethe quality of software architecture – To improve flexibility, understandability, … – Maintenance = 75% of the life of a software n Design patterns « Describe simple and elegant solutions to specific architectural problems in OO software design » – Experience of skillful developers – Recurrent architectural problems
  • 4.
    sic Composite A Ba xample : E pattern solution Composite composes objects into tree structures to represent part-whole hierarchies. It lets clients treat individual objects and compositions of objects uniformly.
  • 5.
    Main ideas n Designpatterns are good micro- architectural solutions n Micro-architectures close to a design pattern solution may be improved n Theseare transformed into the corresponding design pattern solution
  • 6.
    Problem n To identify – The Use of a design pattern solution • Well written code • Notion of complete version – The Misuse of a design pattern solution • Code improvement • Notion of distorted version + No up-front descriptions of the distortions
  • 7.
    ic A Bas xample: Problem E Complete and distorted versions?
  • 8.
    Complete and distortedversions n Related works – The search of sub-graphs in a graph – The phase of adaptation in case-based reasoning n But we need complete and distorted versions Æ Explanation-based CP (eCP)
  • 9.
    Solution n Explanation-based CP enables – Justifications • Programming = « artistic » activity • Explain why / how the code is modified – Complete and distorted versions – Strong interactivity with the user • Dynamic description of the distortions
  • 10.
    Explanation-based CP 1/3 n Setof constraints justifying an action performed by the solver – Value removal – Contradiction n Trace of the solver behavior
  • 11.
    Explanation-based CP 2/3 n Application – Assistance upon failure – Interactive solvers – New search algorithms • Path-repair (AAAI 2000) • Mac-DBT (CP 2000) •…
  • 12.
    Explanation-based CP 3/3 n An implementation: PaLM – Developed at the EMN – On top of Choco – Written in Claire – Used in Path-Repair, Mac-DBT – Reliable and efficient
  • 13.
    Our application n The design pattern solution – A class defines a variable – Relationships among classes define constraints n The source code of the application – The classes define the domain of the variables – Relationships among classes give the semantics of the constraints
  • 14.
    ic A Bas xample: Constraints E n The Composite design pattern solution n Its constraints composite < component leaf < component composite ⊃ component
  • 15.
    ic A Bas xample: Interaction E composite < component leaf < component composite ⊃ component
  • 16.
    ic A Bas xample: Results E
  • 17.
    Our results 1/3 n Implementation – Constraints • Inheritance, creation, composition, … – Design pattern solutions • Composite, Façade, Factory Method, … n Experiments – Small test-cases – JEdit v3.1 (~250 classes), JHotDraw v5.1 (~155 classes), Ptidej itself (!), …
  • 18.
  • 19.
  • 20.
    Conclusion and future nAn application of explanation-based CP – Non-trivial problem n Short term – To add more design pattern solutions – To develop the constraints system • New algorithm CSP-NN [Morning session] – Scalability and weights (noise) n Long term – automation and interaction (usability)