69
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 [email protected] Presentation in Sukyoung Ruy’s group KAIST 2013/06/07

130607 yann-gael gueheneuc - ptidej tool suite

Embed Size (px)

DESCRIPTION

Reverse-engineering, pattern detection, flexibility

Citation preview

Page 1: 130607   yann-gael gueheneuc - ptidej tool suite

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

[email protected] in Sukyoung Ruy’s group

KAIST2013/06/07

Page 2: 130607   yann-gael gueheneuc - ptidej tool suite

Patterns

� Patterns document reusable solutions to recurring problems– Architecture

2/69

• Architectural styles

– Design• Design patterns• Design anti-patterns

– Implementation• Idioms

Page 3: 130607   yann-gael gueheneuc - ptidej tool suite

Patterns

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

3/69

– Among others…

Page 4: 130607   yann-gael gueheneuc - ptidej tool suite

Patterns

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

4/69

– Among others…

Page 5: 130607   yann-gael gueheneuc - ptidej tool suite

Patterns

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

5/69

– Among others…

Page 6: 130607   yann-gael gueheneuc - ptidej tool suite

Patterns

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

6/69

– Among others…

Page 7: 130607   yann-gael gueheneuc - ptidej tool suite

Patterns

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

7/69

– Among others…

Page 8: 130607   yann-gael gueheneuc - ptidej tool suite

Patterns

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

8/69

– Among others…

Page 9: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 10: 130607   yann-gael gueheneuc - ptidej tool suite

Outline

� Patterns� Ptidej Tool Suite

10/69

Page 11: 130607   yann-gael gueheneuc - ptidej tool suite

Outline

� Patterns

� Ptidej Tool Suite

11/69

Page 12: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 13: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 14: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 15: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 16: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 17: 130607   yann-gael gueheneuc - ptidej tool suite

Patterns

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

17/69

– Problem(s)– Solution– Consequences

Page 18: 130607   yann-gael gueheneuc - ptidej tool suite

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)

Page 19: 130607   yann-gael gueheneuc - ptidej tool suite

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:

Page 20: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 21: 130607   yann-gael gueheneuc - ptidej tool suite

Outline

� Patterns� Ptidej Tool Suite

21/69

Page 22: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 23: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 24: 130607   yann-gael gueheneuc - ptidej tool suite

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”

Page 25: 130607   yann-gael gueheneuc - ptidej tool suite

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”

Page 26: 130607   yann-gael gueheneuc - ptidej tool suite

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)

Page 27: 130607   yann-gael gueheneuc - ptidej tool suite

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)

Page 28: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 29: 130607   yann-gael gueheneuc - ptidej tool suite

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)

Page 30: 130607   yann-gael gueheneuc - ptidej tool suite

Ptidej Tool Suite

What to detect?

30/69

How to express it?

In what todetect it?

Page 31: 130607   yann-gael gueheneuc - ptidej tool suite

Ptidej Tool Suite

“Great software is not built, it is grown”

31/69

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

Page 32: 130607   yann-gael gueheneuc - ptidej tool suite

Ptidej Tool Suite

Design Patterns

32/69

PDL meta-model

Models ofOO programs

Page 33: 130607   yann-gael gueheneuc - ptidej tool suite

Ptidej Tool Suite

PDL meta-model

33/69

Page 34: 130607   yann-gael gueheneuc - ptidej tool suite

Ptidej Tool Suite

+ Models of OO programs

PDL meta-model

34/69

+ Models of OO programs

Page 35: 130607   yann-gael gueheneuc - ptidej tool suite

Ptidej Tool Suite

+ Models of OO programs

PDL meta-model

35/69

+ Models of OO programs = PADL meta-model

Page 36: 130607   yann-gael gueheneuc - ptidej tool suite

Ptidej Tool Suite

36/69

PADL Pattern and Abstract-level Description Language

Page 37: 130607   yann-gael gueheneuc - ptidej tool suite

Ptidej Tool Suite

37/69

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

PADL Pattern and Abstract-level Description Language

Page 38: 130607   yann-gael gueheneuc - ptidej tool suite

Ptidej Tool Suite

38/69

PADL Analyses• Binary Class Relationships

• Systematic UML

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

PADL Pattern and Abstract-level Description Language

Page 39: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 40: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 41: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 42: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 43: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 44: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 45: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 46: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 47: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 48: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 49: 130607   yann-gael gueheneuc - ptidej tool suite

49/69PADL Kernel, elementsDescribe methods, fields…

Page 50: 130607   yann-gael gueheneuc - ptidej tool suite

50/69PADL Kernel, entitiesDescribe classes, interfaces…

Page 51: 130607   yann-gael gueheneuc - ptidej tool suite

51/69PADL Kernel, relationshipsDescribe inheritances, associations…

Page 52: 130607   yann-gael gueheneuc - ptidej tool suite

Ptidej Tool Suite

� Advantages– Creators– BCRs

52/69

– Extensibility– Reliability

(Has been used in many studies)

Page 53: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 54: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 55: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 56: 130607   yann-gael gueheneuc - ptidej tool suite

Ptidej Tool Suite

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

56/69

• Quality of the model under tests

Page 57: 130607   yann-gael gueheneuc - ptidej tool suite

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/

Page 58: 130607   yann-gael gueheneuc - ptidej tool suite

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());

}

...

Page 59: 130607   yann-gael gueheneuc - ptidej tool suite

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());

}

...

Page 60: 130607   yann-gael gueheneuc - ptidej tool suite

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());

}

...

Page 61: 130607   yann-gael gueheneuc - ptidej tool suite

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());

}

...

Page 62: 130607   yann-gael gueheneuc - ptidej tool suite

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;

}

Page 63: 130607   yann-gael gueheneuc - ptidej tool suite

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;

}

Page 64: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 65: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 66: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 67: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 68: 130607   yann-gael gueheneuc - ptidej tool suite

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

Page 69: 130607   yann-gael gueheneuc - ptidej tool suite

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