The document discusses research into automating the application and detection of design patterns through the development of tools called PatternsBox and Ptidej, which use a common meta-model to represent design patterns and apply patterns to code or detect patterns in existing code through constraint solving. The goal is to provide a round-trip engineering approach to using design patterns through these tools.
2. Us
n Hervé Albin-Amiot
– 3rd year PhD student
– Partly funded by Soft-Maint S.A. (France)
n Yann-Gaël Guéhéneuc
– 2nd year PhD student
– Partly funded by Object Technology
International, Inc. (Canada)
n PhDs hosted by the
École des Mines de Nantes
3. Overview on design patterns
n Design patterns are useful for:
– Designing
– Implementating
– Documentating
– Re-engineering
n Design patterns are difficult to use:
– Lack of formalism
– And thus, lack of automation
4. Our Goals
n We want:
– To help designer
– To help maintainer
n We do not want:
– To replace the designer
– To be Caliph in the Caliph's stead
n We need to automate the uses of
design patterns
5. Goals of the automation
n We want to assist developers:
– In applying design patterns
– In detecting design patterns
n We want to provide
round-trip using design
patterns
n We need a common
design pattern description
7. Abstract model
Informal descriptions
from [GoF]
Translates into Instance of Pattern
Instance of PInterface
Instance of PClass
Instance of PAssoc
Instance of PDelegation
name() Instance of PMethod
8. PatternsBox
Abstract model Ptidej
Composite pattern concrete model 1 Composite pattern concrete model n
• •
‚ ‚ ‚ ‚
Composite pattern abstract model
• •
Composite pattern concrete model 1 Composite pattern concrete model n
(source code) (source code)
9. ic
A Bas xample : Application 1/4
E
n PatternsBox is a tool to
instantiate design
patterns from a
repository of patterns
10. ic
A Bas xample : Application 2/4
E
n From the pattern, we
access the pattern
description
11. ic
A Bas xample : Application 3/4
E
n We adapt actors and
roles to the current
context
12. ic
A Bas xample : Application 4/4
E
n The tool generates the code of the
pattern for Java (or for PaLM, …)
public interface MyComponent {
public abstract void myOperation();
}
public class MyComposite implements MyComponent {
// Association: myChildren
private java.util.Vector myChildren = new java.util.Vector();
public void add (MyComponent myComponent) {
myChildren.addElement(myComponent);
}
public void remove (MyComponent myComponent) {
myChildren.removeElement(myComponent);
}
// Method linked to: myChildren
public void myOperation() {
for (Enumeration enum= myChildren.elements();
enum.hasMoreElements (); ((MyComponent)
enum.nextElement()).myOperation());
}
}
public class MyLeaf implements MyComponent {
public void myOperation() {
}
}
13. ic
A Bas xample : Detection 1/6
E
n Ptidej detects instances
of the abstract model
14. ic
A Bas xample : Detection 2/6
E
n It is a tool that identifies design patterns
n It loads and
displays an
application
architecture
15. ic
A Bas xample : Detection 3/6
E
n Itgenerates a CSP from the
architecture
n The CSP has
the architecture
for model and
the abstract
model for
constraints
16. ic
A Bas xample : Detection 4/6
E
The PaLM explanation-based constraint solver
17. ic
A Bas xample : Detection 5/6
E
n Thetool highlights the distorted and
complete design patterns found in the
architecture
18. ic
A Bas xample : Detection 6/6
E
n The tool states the differences between
the distorted solutions and the abstract
model
19. Future 1/2
n To have two separate meta-models
– One specific for design patterns
– One specific for source code
n To extend PatternsBox to apply design
patterns to existing code using a
source-to-source transformation engine
n To use XML for the patterns repository
and XSLT to generate Java examples
20. Future 2/2
n To take few months of holidays
n To manage dynamic information
n To define an operational semantics for
association, aggregation, … links
n To improve the
constraints
n To integrate our
tools with IDEs