130607 yann-gael gueheneuc - ptidej tool suite

Preview:

DESCRIPTION

Reverse-engineering, pattern detection, flexibility

Citation preview

Ptidej Tool Suite

Yann-Gaël Guéhéneuc

Département de génie informatique et de génie logiciel

This work is licensed under a Creative Commons Attribution-NonCommercial-

ShareAlike 3.0 Unported License

yann-gael.gueheneuc@polytmtl.caPresentation in Sukyoung Ruy’s group

KAIST2013/06/07

Patterns

� Patterns document reusable solutions to recurring problems– Architecture

2/69

• Architectural styles

– Design• Design patterns• Design anti-patterns

– Implementation• Idioms

Patterns

� Several books, articles– “Theoretical”– With examples

3/69

– Among others…

Patterns

� Several books, articles– “Theoretical”– With examples

4/69

– Among others…

Patterns

� Several books, articles– “Theoretical”– With examples

5/69

– Among others…

Patterns

� Several books, articles– “Theoretical”– With examples

6/69

– Among others…

Patterns

� Several books, articles– “Theoretical”– With examples

7/69

– Among others…

Patterns

� Several books, articles– “Theoretical”– With examples

8/69

– Among others…

Patterns

“[E]xisting books on design patterns take a catalog approach, where they show the individual design patterns in isolation. This approach is […] flawed, because you can't see

9/69

approach is […] flawed, because you can't see how the design patterns actually function in the real world. Most programmers learn by looking at computer programs.”

—Allen Holub in Holub on Patterns: LearningDesign Patterns by Looking at Code

Outline

� Patterns� Ptidej Tool Suite

10/69

Outline

� Patterns

� Ptidej Tool Suite

11/69

Patterns

� Several books, articles– Amazon.com

• Books › Computers & Technology › Programming › Software Design, Testing & Engineering › Object-

12/69

Software Design, Testing & Engineering › Object-Oriented Design › "patterns"

• 224 results on May 31, 2013

Patterns

� Several books, articles– Amazon.com

• Exclusion– Unreleased books

13/69

– Unreleased books– Specific to a technology or frameworks

» e.g., MVVM Unleashed by Michael Brown– Process oriented, user-interface, programming languages

» e.g., Process Patterns: Building Large-Scale Systems Using Object Technology by Scott W. Ambler and Barbara Hanscome

– Proceedings of conferences– Unrelated to software engineering

Patterns1. Pattern-Oriented Software Architecture, Patterns for Concurrent and Networked Objects: Volume 2 (Wiley Software...

by Douglas C. Schmidt, Michael Stal, Hans Rohnert and Frank Buschmann

2. Pattern-Oriented Software Architecture, Patterns for Resource Management: Volume 3 (Wiley Software Patterns Series... by Michael Kircher and Prashant Jain

3. Pattern-Oriented Software Architecture, A System of Patterns: Volume 1 (Wiley Software Patterns Series) by Frank Buschmann, Regine Meunier, Hans Rohnert and Peter Sommerlad

4. Pattern-Oriented Software Architecture For Dummies (For Dummies (Computers)) by Robert Hanmer5. Web Security Patterns by Ramesh Nagappan and Christopher Steel6. Safe C++ by Vladimir Kushnir

7. Programming in the Large with Design Patterns by Eddie Burris8. Elemental Design Patterns by Jason McC. Smith9. Java Application Architecture: Modularity Patterns with Examples Using OSGi (Robert C. Martin Series) by Kirk

Knoernschild10. Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions (Addison-Wesley

Signature... by Gregor Hohpe and Bobby Woolf11. Patterns of Enterprise Application Architecture (Addison-Wesley Signature Series (Fowler)) by Martin Fowler

12. Cognitive Patterns: Problem-Solving Frameworks for Object Technology by Robert K Konitzer, Bobbin Teegarden, Alexander Rush and Karen M Gardner

13. Service Design Patterns: Fundamental Design Solutions for SOAP/WSDL and RESTful Web Services by Robert Daigneau

14. The ACE Programmer's Guide: Practical Design Patterns for Network and Systems Programming by Stephen D.

37. Object-Oriented Modeling and Design with UML (2nd Edition) by Michael R. Blaha and James R Rumbaugh

38. Remoting Patterns: Foundations of Enterprise, Internet and Realtime Distributed Object Middleware (Wiley Software... by Markus Völter, Michael Kircher and Uwe Zdun

39. Software Factories: Assembling Applications with Patterns, Models, Frameworks, and Tools (Wiley Application Development... by Jack Greenfield, Keith Short, Steve Cook and Stuart Kent

40. Refactoring to Patterns by Joshua Kerievsky41. Architecting Enterprise Solutions: Patterns for High-Capability Internet-based Systems (Wiley Software Patterns...

by Paul Dyson and Andrew Longshaw42. Enterprise Patterns and MDA: Building Better Software with Archetype Patterns and UML by Jim Arlow and Ila

Neustadt

43. Data Access Patterns: Database Interactions in Object-Oriented Applications by Clifton Nock44. Domain-Driven Design: Tackling Complexity in the Heart of Software by Eric Evans45. Pattern-Oriented Analysis and Design: Composing Patterns to Design Software Systems by Sherif M. Yacoub,

Hany H. Ammar, Sherif Yacoub and Hany Ammar46. Java Extreme Programming Cookbook by Eric M. Burke and Brian M. Coyner47. J2EE Best Practices: Java Design Patterns, Automation, and Performance (Wiley Application Development

Series) by Darren Broemmer

48. Real-Time Design Patterns: Robust Scalable Architecture for Real-Time Systems by Bruce Powel Douglass49. Design Patterns Java¿ Workbook by Steven John Metsker50. EJB Design Patterns: Advanced Patterns, Processes, and Idioms by Floyd Marinescu

14/69

14. The ACE Programmer's Guide: Practical Design Patterns for Network and Systems Programming by Stephen D. Huston, James CE Johnson and Umar Syyid

15. Patterns for Parallel Software Design (Wiley Software Patterns Series) by Jorge Luis Ortega-Arjona16. Design Patterns in Object-oriented ABAP by Igor Barbaric

17. Object-Oriented Reengineering Patterns by Oscar Nierstrasz, Stéphane Ducasse and Serge Demeyer18. Dependency Injection by Dhanji R. Prasanna19. Object-Oriented Software Engineering Using UML, Patterns, and Java (3rd Edition) by Bernd Bruegge and Allen H.

Dutoit20. J2EE Design Patterns by William Crawford and Jonathan Kaplan21. Applying UML and Patterns: An Introduction to Object-oriented Analysis and Design and Iterative Development by

Craig Larman

22. Object-oriented Analysis and Design Using Umlan Introduction to Unified Process and Design Patterns by Mahesh P. Matha

23. C++ Design Patterns and Derivatives Pricing (Mathematics, Finance and Risk) by M. S. Joshi24. Effective Java (2nd Edition) by Joshua Bloch25. Patterns for Fault Tolerant Software (Wiley Software Patterns Series) by Robert Hanmer26. Implementation Patterns by Kent Beck

27. Patterns for Computer-Mediated Interaction (Wiley Software Patterns Series) by Till Schummer and Stephan Lukosch28. Pattern Oriented Software Architecture Volume 5: On Patterns and Pattern Languages by Frank Buschmann, Kevlin

Henney and Douglas C. Schmidt29. Object-Oriented Analysis and Design with Applications (3rd Edition) by Grady Booch, Robert A. Maksimchuk, Michael

W. Engle and Bobbi J. Young30. Head First Object-Oriented Analysis and Design by Brett D. McLaughlin, Gary Pollice and Dave West 31. Agile Principles, Patterns, and Practices in C# by Robert C. Martin and Micah Martin

32. Design Patterns For Dummies by Steve Holzner33. Pattern Languages of Program Design 5 by Dragos Manolescu, Markus Voelter and James Noble34. Design Patterns in Java(TM) (Software Patterns Series) by Steven John Metsker and William C. Wake35. Object-Oriented Design and Patterns by Cay S. Horstmann

51. Streamlined Object Modeling: Patterns, Rules, and Implementation by Jill Nicola, Mark Mayfield and Mike Abney52. Design Patterns Explained: A New Perspective on Object-Oriented Design by Alan Shalloway and James Trott

53. Small Memory Software: Patterns for systems with limited memory (Software Patterns Series) by James Noble and Charles Weir

54. AntiPatterns in Project Management by William J. Brown, Hays W. "Skip" McCormick III and Scott W. Thomas55. Pattern Languages of Program Design 4 (Software Patterns Series) by Brian Foote, Neil Harrison and Hans

Rohnert56. Testing Object-Oriented Systems: Models, Patterns, and Tools by Robert V. Binder57. Design Patterns and Contracts by Jean-Marc Jezequel, Michel Train and Christine Mingins

58. Object-Oriented Software Development Using Java: Principles, Patterns, and Frameworks (1/e) by Xiaoping Jia59. Refactoring: Improving the Design of Existing Code by Martin Fowler, Kent Beck, John Brant and William Opdyke60. More Process Patterns: Delivering Large-Scale Systems Using Object Technology (SIGS: Managing Object

Technology... by Scott W. Ambler61. Pattern Hatching: Design Patterns Applied by John Vlissides62. AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J. Brown, Raphael C. Malveau,

Hays W. "Skip" McCormick and Thomas J. Mowbray

63. A Little Java, A Few Patterns (Language, Speech, & Communication) by Matthias Felleisen, Daniel P. Friedman and Ralph E. Johnson

64. Pattern Languages of Program Design 3 (v. 3) by Robert C. Martin, Dirk Riehle and Frank Buschmann65. Object Models: Strategies, Patterns, and Applications (2nd Edition) by Peter Coad, David North and Mark Mayfield66. Analysis Patterns: Reusable Object Models by Martin Fowler67. Patterns of Software: Tales from the Software Community by Richard P. Gabriel

68. Pattern Languages of Program Design 2 (v. 2) by John Vlissides, James O. Coplien and Norman L. Kerth69. Software Patterns by James Coplien70. Software Architecture: Perspectives on an Emerging Discipline by Mary Shaw and David Garlan71. Adaptive Object-Oriented Software: The Demeter Method with Propagation Patterns: The Demeter Method with

Propagation... by Karl Lieberherr72. Pattern Languages of Program Design by James O. Coplien and Douglas C. Schmidt

Patterns

� The following is not a substitute to reading previous books and practicing

15/69

� The following is complementary to reading books and practicing– These patterns that have been “found” the hard

way and that work (or do not work!)

Patterns

� The following is not a substitute to reading these books and practicing

16/69

� The following is complementary to reading books and practicing– These patterns that have been “found” the hard

way and that work (or do not work!)

Patterns

� General form as for the GoF , also inspired by Coplien’s form– Name

17/69

– Problem(s)– Solution– Consequences

Patterns

� General form as for the GoF, also inspired by Coplien’s form– Name

18/69

– Problem(s)

– Example(s)

– Solution– Example(s)

– Consequences– (Follow-up)

Patterns

� General form as for the GoF, also inspired by Coplien’s form– Name

19/69

– Problem(s)

– Example(s)

– Solution– Example(s)

– Consequences– (Follow-up)

Problem:Solution:

Patterns

� General form as for the GoF, also inspired by Coplien’s form– Not formal

20/69

– Room for interpretation

– But…• UML-like class diagrams• UML-like sequence diagrams• Smalltalk / C++ example code

Outline

� Patterns� Ptidej Tool Suite

21/69

Ptidej Tool Suite

� Context– Research work started since my Ph.D. thesis

(2000–2003)– Pattern Trace Identification, Detection, and

22/69

– Pattern Trace Identification, Detection, and Enhancement in Java

• Theories, methods, and tools, to evaluate and to improve the quality of object-oriented programs by promoting the use of idioms, design patterns, and architectural patterns

Ptidej Tool Suite

� Requirements– Software tools

• Support the analysis of the implementation, design, and architecture of object-oriented programs

23/69

and architecture of object-oriented programs• Support the detection and introduction of patterns at

the code, design, and architectural levels

Ptidej Tool Suite

� Analysis– Domain concepts

• “quality of object-oriented”• “promoting the use of idioms, design patterns, and

24/69

• “promoting the use of idioms, design patterns, and architectural patterns”

• “analysis of the implementation, design, and architecture of object-oriented programs”

• “detection and introduction of patterns at the code, design, and architectural levels”

Ptidej Tool Suite

� Analysis– Domain concepts

• “quality of object-oriented”• “promoting the use of idioms, design patterns, and

25/69

• “promoting the use of idioms, design patterns, and architectural patterns”

• “analysis of the implementation, design, and architecture of object-oriented programs”

• “detection and introduction of patterns at the code, design, and architectural levels”

Ptidej Tool Suite

� Constraint– Apply patterns/best practices (existing or new)

when developing the tools• Architectural

26/69

• Architectural• Design• Implementation

– Self-imposed but sensible• “Eating your own dog food”

(http://www.urbandictionary.com/define.php? term=eating%20your%20own%20dog%20food)

Ptidej Tool Suite

� Related work– Various parsers (target languages)

e.g., GCCXML

– Various meta-model (sometimes implicit)

27/69

– Various meta-model (sometimes implicit)• Similar to UML meta-model (1997)• Before OMG KDM (2003)• Before Eclipse EMF (2004)• Before OMG MOF (2006)

– Various toolse.g., Rigi (H. M. Kienle and H. A. Müller: Rigi – An environment for software reverse engineering, exploration, visualization, and redocumentation. Sci. Comput. Program. 75(4): 247-263, 2010)

Ptidej Tool Suite

� Related work↑ Existing ☺

↓ Too low-level

28/69

↓ Too low-levele.g., GCCXML

↓ No “free” parserse.g., UML meta-model

↓ Difficult to access / to use / to adapte.g., Rigi

Ptidej Tool Suite

� Related work– Pierre Cointe’s team in 2000 at École des Mines

de Nantes, France– Fertile ground

29/69

– Fertile ground• Hervé Albin-Amiot was already developing a meta-

model to describe design patterns– “Idioms and patterns Java: application to code synthesis and

detection” (Ph.D. in 2003) – PDL (Pattern Description Language)

Ptidej Tool Suite

What to detect?

30/69

How to express it?

In what todetect it?

Ptidej Tool Suite

“Great software is not built, it is grown”

31/69

—Bill de hÓra in 97 Things EverySoftware Architect Should Know

Ptidej Tool Suite

Design Patterns

32/69

PDL meta-model

Models ofOO programs

Ptidej Tool Suite

PDL meta-model

33/69

Ptidej Tool Suite

+ Models of OO programs

PDL meta-model

34/69

+ Models of OO programs

Ptidej Tool Suite

+ Models of OO programs

PDL meta-model

35/69

+ Models of OO programs = PADL meta-model

Ptidej Tool Suite

36/69

PADL Pattern and Abstract-level Description Language

Ptidej Tool Suite

37/69

PADL CreatorsC++, C#, Java, JavaScript?

PADL Pattern and Abstract-level Description Language

Ptidej Tool Suite

38/69

PADL Analyses• Binary Class Relationships

• Systematic UML

PADL CreatorsC++, C#, Java, JavaScript?

PADL Pattern and Abstract-level Description Language

Ptidej Tool Suite

PADL Generators

39/69

PADL GeneratorsXMI…

PADL Analyses• Binary Class Relationships

• Systematic UML

PADL CreatorsC++, C#, Java, JavaScript?

PADL Pattern and Abstract-level Description Language

Ptidej Tool Suite

PADL Generators

40/69

PADL SerialisersDB4O, JOS…

PADL GeneratorsXMI…

PADL Analyses• Binary Class Relationships

• Systematic UML

PADL CreatorsC++, C#, Java, JavaScript?

PADL Pattern and Abstract-level Description Language

Ptidej Tool Suite

PADL Generators

41/69

PADL SerialisersDB4O, JOS…

PADL GeneratorsXMI…

PADL Design MotifsAnti-patterns, code smells, and µ-patterns

PADL Analyses• Binary Class Relationships

• Systematic UML

PADL CreatorsC++, C#, Java, JavaScript?

PADL Pattern and Abstract-level Description Language

Ptidej Tool Suite

POMPADL Generators

42/69

POMPrimitives, Operations, Metrics

PADL SerialisersDB4O, JOS…

PADL GeneratorsXMI…

PADL Design MotifsAnti-patterns, code smells, and µ-patterns

PADL Analyses• Binary Class Relationships

• Systematic UML

PADL CreatorsC++, C#, Java, JavaScript?

PADL Pattern and Abstract-level Description Language

Ptidej Tool Suite

(Ptidej Solver)Identification of design motifs

POMPADL Generators

43/69

POMPrimitives, Operations, Metrics

PADL SerialisersDB4O, JOS…

PADL GeneratorsXMI…

PADL Design MotifsAnti-patterns, code smells, and µ-patterns

PADL Analyses• Binary Class Relationships

• Systematic UML

PADL CreatorsC++, C#, Java, JavaScript?

PADL Pattern and Abstract-level Description Language

Ptidej Tool Suite

SADIdentification of anti-patterns

(Ptidej Solver)Identification of design motifs

POMPADL Generators

44/69

POMPrimitives, Operations, Metrics

PADL SerialisersDB4O, JOS…

PADL GeneratorsXMI…

PADL Design MotifsAnti-patterns, code smells, and µ-patterns

PADL Analyses• Binary Class Relationships

• Systematic UML

PADL CreatorsC++, C#, Java, JavaScript?

PADL Pattern and Abstract-level Description Language

Ptidej Tool Suite

SADIdentification of anti-patterns

(Ptidej Solver)Identification of design motifs

POMPADL Generators

Ptidej UIUser interface (using reflection)

45/69

POMPrimitives, Operations, Metrics

PADL SerialisersDB4O, JOS…

PADL GeneratorsXMI…

PADL Design MotifsAnti-patterns, code smells, and µ-patterns

PADL Analyses• Binary Class Relationships

• Systematic UML

PADL CreatorsC++, C#, Java, JavaScript?

PADL Pattern and Abstract-level Description Language

46/69Ptidej UI Viewer Standalone Swing displaying PADL(Another example of “Eating your own dog food” ☺)

47/69PADL Kernel, main interfaces provided to the users(SVG and JPG from Ptidej UI Viewer Standalone Swing)

48/69PADL Kernel, abstract-level modelsDescribe models of programs, including design motifs

49/69PADL Kernel, elementsDescribe methods, fields…

50/69PADL Kernel, entitiesDescribe classes, interfaces…

51/69PADL Kernel, relationshipsDescribe inheritances, associations…

Ptidej Tool Suite

� Advantages– Creators– BCRs

52/69

– Extensibility– Reliability

(Has been used in many studies)

Ptidej Tool Suite

� Advantages– Available! ☺

• https://web.soccerlab.polymtl.ca/rptidej/ptidejlab/ Software/Ptidej 5 Workspace

53/69

Software/Ptidej 5 Workspace• Username: guestsvn• Password: g1u2e3s4t5

– See also• http://www.ptidej.net/material/inanutshell• http://www.ptidej.net/material/development/• http://wiki.ptidej.net/doku.php

Ptidej Tool Suite

� Advantages– Extensible

e.g., C++ creator provide new/modified constituent

54/69

• Factory design pattern• Builder design pattern

– Including for the user interface

Ptidej Tool Suite

� Limits– Coarse representation

of method statements

55/69

– Unsatisfactory support of non-typed, non-object-oriented programming languages

• (Very) partial support for Smalltalk

Ptidej Tool Suite

� Performance– Eclipse v3.1– Google Chrome v1.0.154.53

56/69

• Quality of the model under tests

Ptidej Tool Suite

� Academic Usage– Dozen of empirical studies

e.g., S. Kpodjedo, F. Ricca, P. Galinier, G. Antoniol, and Y.-G. Guéhéneuc. MADMatch: Many-to-many

57/69

and Y.-G. Guéhéneuc. MADMatch: Many-to-many Approximate Diagram Matching for Design Comparison. IEEE TSE, Feburary 2013

– Please see• http://www.ptidej.net/publications/

Ptidej Tool Suite

� Concrete Usage– Build a model from some C++ code (1/2)

public static IIdiomLevelModel generateModelFromCppFilesUsingEclipse(

final String aName,

final String aSourceDirectory,

58/69

final String aSourceDirectory,

final IModelListener aModelListener) {

ICodeLevelModel codeLevelModel = null;

try {

final ICodeLevelModelCreator creator =

new padl.creator.cppfile.eclipse.CppCreator(aSourceDirectory);

codeLevelModel =

CPPFactoryEclipse.getInstance().createCodeLevelModel(aName);

if (aModelListener != null) {

codeLevelModel.addModelListener(aModelListener);

}

codeLevelModel.create(creator);

}

catch (final CreationException e) {

e.printStackTrace(ProxyConsole.getInstance().errorOutput());

}

...

Ptidej Tool Suite

� Concrete Usage– Build a model from some C++ code (1/2)

public static IIdiomLevelModel generateModelFromCppFilesUsingEclipse(

final String aName,

final String aSourceDirectory,

Specialised creator

59/69

final String aSourceDirectory,

final IModelListener aModelListener) {

ICodeLevelModel codeLevelModel = null;

try {

final ICodeLevelModelCreator creator =

new padl.creator.cppfile.eclipse.CppCreator(aSourceDirectory);

codeLevelModel =

CPPFactoryEclipse.getInstance().createCodeLevelModel(aName);

if (aModelListener != null) {

codeLevelModel.addModelListener(aModelListener);

}

codeLevelModel.create(creator);

}

catch (final CreationException e) {

e.printStackTrace(ProxyConsole.getInstance().errorOutput());

}

...

Ptidej Tool Suite

� Concrete Usage– Build a model from some C++ code (1/2)

public static IIdiomLevelModel generateModelFromCppFilesUsingEclipse(

final String aName,

final String aSourceDirectory,

Specialised creator

Specialised factory to

allow new constituents

60/69

final String aSourceDirectory,

final IModelListener aModelListener) {

ICodeLevelModel codeLevelModel = null;

try {

final ICodeLevelModelCreator creator =

new padl.creator.cppfile.eclipse.CppCreator(aSourceDirectory);

codeLevelModel =

CPPFactoryEclipse.getInstance().createCodeLevelModel(aName);

if (aModelListener != null) {

codeLevelModel.addModelListener(aModelListener);

}

codeLevelModel.create(creator);

}

catch (final CreationException e) {

e.printStackTrace(ProxyConsole.getInstance().errorOutput());

}

...

Ptidej Tool Suite

� Concrete Usage– Build a model from some C++ code (1/2)

public static IIdiomLevelModel generateModelFromCppFilesUsingEclipse(

final String aName,

final String aSourceDirectory,

Specialised creator

Specialised factory to

allow new constituents

Builder design pattern

61/69

final String aSourceDirectory,

final IModelListener aModelListener) {

ICodeLevelModel codeLevelModel = null;

try {

final ICodeLevelModelCreator creator =

new padl.creator.cppfile.eclipse.CppCreator(aSourceDirectory);

codeLevelModel =

CPPFactoryEclipse.getInstance().createCodeLevelModel(aName);

if (aModelListener != null) {

codeLevelModel.addModelListener(aModelListener);

}

codeLevelModel.create(creator);

}

catch (final CreationException e) {

e.printStackTrace(ProxyConsole.getInstance().errorOutput());

}

...

Ptidej Tool Suite

� Concrete Usage– Build a model from some C++ code (2/2)public static IIdiomLevelModel generateModelFromCppFilesUsingEclipse(

final String aName,

final String aSourceDirectory,

62/69

final String aSourceDirectory,

final IModelListener aModelListener) {

...

IIdiomLevelModel idiomLevelModel = null;

try {

idiomLevelModel =

(IIdiomLevelModel) new AACRelationshipsAnalysis().invoke(aCodeLevelModel);

}

catch (final UnsupportedSourceModelException e) {

e.printStackTrace(ProxyConsole.getInstance().errorOutput());

}

return idiomLevelModel;

}

Ptidej Tool Suite

� Concrete Usage– Build a model from some C++ code (2/2)public static IIdiomLevelModel generateModelFromCppFilesUsingEclipse(

final String aName,

final String aSourceDirectory,

Promotion of the model

63/69

final String aSourceDirectory,

final IModelListener aModelListener) {

...

IIdiomLevelModel idiomLevelModel = null;

try {

idiomLevelModel =

(IIdiomLevelModel) new AACRelationshipsAnalysis().invoke(aCodeLevelModel);

}

catch (final UnsupportedSourceModelException e) {

e.printStackTrace(ProxyConsole.getInstance().errorOutput());

}

return idiomLevelModel;

}

Ptidej Tool Suite

� Concrete Usage– Identify occurrence of the Composite DMfinal Problem problem =

CompositeMotif.getProblem(Manager.build(idiomLevelModel));

64/69

final StringWriter writer = new StringWriter();

problem.setWriter(new PrintWriter(writer));

problem.automaticSolve(true);

final Properties properties = new Properties();

properties.load(new ReaderInputStream(new StringReader(writer.getBuffer().toString())));

final OccurrenceBuilder solutionBuilder = OccurrenceBuilder.getInstance();

final Occurrence[] solutions = solutionBuilder.getCanonicalOccurrences(properties);

Ptidej Tool Suite

� Concrete Usage– Identify occurrence of the Composite DMfinal Problem problem =

CompositeMotif.getProblem(Manager.build(idiomLevelModel));

From a library of

design motifs

65/69

final StringWriter writer = new StringWriter();

problem.setWriter(new PrintWriter(writer));

problem.automaticSolve(true);

final Properties properties = new Properties();

properties.load(new ReaderInputStream(new StringReader(writer.getBuffer().toString())));

final OccurrenceBuilder solutionBuilder = OccurrenceBuilder.getInstance();

final Occurrence[] solutions = solutionBuilder.getCanonicalOccurrences(properties);

Ptidej Tool Suite

� Concrete Usage– Identify occurrence of the Blob anti-patternfinal IDesignSmellDetection detection = (IDesignSmellDetection) new BlobDetection();

detection.setMetricsFileRepository(ClassFileRepository.getInstance(Repository.class));

detection.setModel(idiomLevelModel);

66/69

detection.setModel(idiomLevelModel);

detection.performDetection();

final String path = ...;

detection.output(new PrintWriter(ProxyDisk.getInstance().fileTempOutput(path)));

final Properties properties = new Properties();

properties.load(new ReaderInputStream(ProxyDisk.getInstance().fileTempInput(path)));

final OccurrenceBuilder solutionBuilder = OccurrenceBuilder.getInstance();

final Occurrence[] solutions = solutionBuilder.getCanonicalOccurrences(properties);

Ptidej Tool Suite

� Concrete Usage– Identify occurrence of the Blob anti-patternfinal IDesignSmellDetection detection = (IDesignSmellDetection) new BlobDetection();

detection.setMetricsFileRepository(ClassFileRepository.getInstance(Repository.class));

detection.setModel(idiomLevelModel);

From a library of

anti-patterns

67/69

detection.setModel(idiomLevelModel);

detection.performDetection();

final String path = ...;

detection.output(new PrintWriter(ProxyDisk.getInstance().fileTempOutput(path)));

final Properties properties = new Properties();

properties.load(new ReaderInputStream(ProxyDisk.getInstance().fileTempInput(path)));

final OccurrenceBuilder solutionBuilder = OccurrenceBuilder.getInstance();

final Occurrence[] solutions = solutionBuilder.getCanonicalOccurrences(properties);

Ptidej Tool Suite

� Limitations and future work– Treatment and modelling of method bodies

• Coarse grain multi-language support for method bodies currently available

68/69

bodies currently available• Fine grain through meta-model extension

– Treatment and modelling of non-typed, non-object-oriented programming languages

• Unsatisfactory support for Smalltalk• No support for PHP, JavaScript

Ptidej Tool Suite

� Limitations and future work– Treatment and modelling of method bodies

• Coarse grain multi-language support for method bodies currently available

69/69

bodies currently available• Fine grain through meta-model extension

– Treatment and modelling of non-typed, non-object-oriented programming languages

• Unsatisfactory support for Smalltalk• No support for PHP, JavaScript