Ptidej Tool Suite
Yann-Gaël Guéhéneuc
yann-gael.gueheneuc@polytmtl.ca
Presentation in Sukyoung Ruy’s group
KAIST
2013/06/0...
Patterns
Patterns document reusable solutions to
recurring problems
– Architecture
• Architectural styles

– Design
• Desi...
Patterns
Several books, articles
– “Theoretical”
– With examples
– Among others…

3/69
Patterns
Several books, articles
– “Theoretical”
– With examples
– Among others…

4/69
Patterns
Several books, articles
– “Theoretical”
– With examples
– Among others…

5/69
Patterns
Several books, articles
– “Theoretical”
– With examples
– Among others…

6/69
Patterns
Several books, articles
– “Theoretical”
– With examples
– Among others…

7/69
Patterns
Several books, articles
– “Theoretical”
– With examples
– Among others…

8/69
Patterns
“[E]xisting books on design patterns take a
catalog approach, where they show the
individual design patterns in i...
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 & ...
Patterns
Several books, articles
– Amazon.com
• Exclusion
– Unreleased books
– Specific to a technology or frameworks
» e....
Patterns
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31...
Patterns
The following is not a substitute to reading
previous books and practicing
The following is complementary to read...
Patterns
The following is not a substitute to reading
these books and practicing
The following is complementary to reading...
Patterns
General form as for the GoF , also inspired
by Coplien’s form
– Name
– Problem(s)
– Solution
– Consequences

17/6...
Patterns
General form as for the GoF, also inspired
by Coplien’s form
– Name
– Problem(s)
– Example(s)
– Solution
– Exampl...
Patterns
General form as for the GoF, also inspired
by Coplien’s form
– Name
– Problem(s)
– Example(s)
– Solution
– Exampl...
Patterns
General form as for the GoF, also inspired
by Coplien’s form
– Not formal
– Room for interpretation
– But…
• UML-...
Outline
Patterns
Ptidej Tool Suite

21/69
Ptidej Tool Suite
Context
– Research work started since my Ph.D. thesis
(2000–2003)
– Pattern Trace Identification, Detect...
Ptidej Tool Suite
Requirements
– Software tools
• Support the analysis of the implementation, design,
and architecture of ...
Ptidej Tool Suite
Analysis
– Domain concepts
• “quality of object-oriented”
• “promoting the use of idioms, design pattern...
Ptidej Tool Suite
Analysis
– Domain concepts
• “quality of object-oriented”
• “promoting the use of idioms, design pattern...
Ptidej Tool Suite
Constraint
– Apply patterns/best practices (existing or new)
when developing the tools
• Architectural
•...
Ptidej Tool Suite
Related work
– Various parsers (target languages)
e.g., GCCXML

– Various meta-model (sometimes implicit...
Ptidej Tool Suite
Related work
↑ Existing ☺
↓ Too low-level
e.g., GCCXML

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

↓ Diff...
Ptidej Tool Suite
Related work
– Pierre Cointe’s team in 2000 at École des Mines
de Nantes, France
– Fertile ground
• Herv...
Ptidej Tool Suite
What to detect?

In what to
detect it?

How to
express it?
30/69
Ptidej Tool Suite

“Great software is not built, it is grown”
—Bill de hÓra in 97 Things Every
Software Architect Should K...
Ptidej Tool Suite
Design Patterns

Models of
OO programs

PDL metamodel
32/69
Ptidej Tool Suite

PDL meta-model

33/69
Ptidej Tool Suite

+

PDL meta-model
Models of OO programs

34/69
Ptidej Tool Suite

+
=

PDL meta-model
Models of OO programs
PADL meta-model

35/69
Ptidej Tool Suite

PADL
Pattern and Abstract-level Description Language

36/69
Ptidej Tool Suite

PADL Creators
C++, C#, Java, JavaScript?
PADL
Pattern and Abstract-level Description Language

37/69
Ptidej Tool Suite

PADL Analyses
• Binary Class Relationships
• Systematic UML
PADL Creators
C++, C#, Java, JavaScript?
PA...
Ptidej Tool Suite

PADL Generators
XMI…
PADL Analyses
• Binary Class Relationships
• Systematic UML
PADL Creators
C++, C#,...
Ptidej Tool Suite

PADL Generators
XMI…
PADL Analyses
• Binary Class Relationships
• Systematic UML
PADL Creators
C++, C#,...
Ptidej Tool Suite

PADL Generators
XMI…
PADL Analyses
• Binary Class Relationships
• Systematic UML

PADL Design Motifs
An...
Ptidej Tool Suite

PADL Generators
XMI…

POM
Primitives, Operations, Metrics

PADL Analyses
• Binary Class Relationships
•...
Ptidej Tool Suite
(Ptidej Solver)
Identification of design motifs
PADL Generators
XMI…

POM
Primitives, Operations, Metric...
Ptidej Tool Suite
(Ptidej Solver)
Identification of design motifs

SAD
Identification of anti-patterns

PADL Generators
XM...
Ptidej Tool Suite
Ptidej UI
User interface (using reflection)
(Ptidej Solver)
Identification of design motifs

SAD
Identif...
Ptidej UI Viewer Standalone Swing displaying PADL
(Another example of “Eating your own dog food” ☺)

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

47/69
PADL Kernel, abstract-level models
Describe models of programs, including design motifs

48/69
PADL Kernel, elements
Describe methods, fields…

49/69
PADL Kernel, entities
Describe classes, interfaces…

50/69
PADL Kernel, relationships
Describe inheritances, associations…

51/69
Ptidej Tool Suite
Advantages
– Creators
– BCRs
– Extensibility
– Reliability
(Has been used in many studies)

52/69
Ptidej Tool Suite
Advantages
– Available! ☺
• https://web.soccerlab.polymtl.ca/rptidej/ptidejlab/
Software/Ptidej 5 Worksp...
Ptidej Tool Suite
Advantages
– Extensible
e.g., C++ creator provide new/modified constituent

• Factory design pattern
• B...
Ptidej Tool Suite
Limits
– Coarse representation
of method statements

– Unsatisfactory support of non-typed, non-objector...
Ptidej Tool Suite
Performance
– Eclipse v3.1
– Google Chrome v1.0.154.53
• Quality of the model under tests

56/69
Ptidej Tool Suite
Academic Usage
– Dozen of empirical studies
e.g., S. Kpodjedo, F. Ricca, P. Galinier, G. Antoniol,
and Y...
Ptidej Tool Suite
Concrete Usage
– Build a model from some C++ code (1/2)
public static IIdiomLevelModel generateModelFrom...
Specialised creator

Ptidej Tool Suite
Concrete Usage
– Build a model from some C++ code (1/2)
public static IIdiomLevelMo...
Specialised creator

Ptidej Tool Suite
Concrete Usage

Specialised factory to
allow new constituents

– Build a model from...
Specialised creator

Ptidej Tool Suite
Concrete Usage

Specialised factory to
allow new constituents
Builder design patter...
Ptidej Tool Suite
Concrete Usage
– Build a model from some C++ code (2/2)
public static IIdiomLevelModel generateModelFrom...
Promotion of the model

Ptidej Tool Suite
Concrete Usage
– Build a model from some C++ code (2/2)
public static IIdiomLeve...
Ptidej Tool Suite
Concrete Usage
– Identify occurrence of the Composite DM
final Problem problem =
CompositeMotif.getProbl...
Ptidej Tool Suite

From a library of
design motifs

Concrete Usage
– Identify occurrence of the Composite DM
final Problem...
Ptidej Tool Suite
Concrete Usage
– Identify occurrence of the Blob anti-pattern
final IDesignSmellDetection detection = (I...
Ptidej Tool Suite

From a library of
anti-patterns

Concrete Usage
– Identify occurrence of the Blob anti-pattern
final ID...
Ptidej Tool Suite
Limitations and future work
– Treatment and modelling of method bodies
• Coarse grain multi-language sup...
Ptidej Tool Suite
Limitations and future work
– Treatment and modelling of method bodies
• Coarse grain multi-language sup...
Upcoming SlideShare
Loading in …5
×

130607 yann-gael gueheneuc - ptidej tool suite

598 views

Published on

Reverse-engineering, pattern detection, flexibility

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
598
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

130607 yann-gael gueheneuc - ptidej tool suite

  1. 1. Ptidej Tool Suite Yann-Gaël Guéhéneuc yann-gael.gueheneuc@polytmtl.ca Presentation in Sukyoung Ruy’s group KAIST 2013/06/07 Département de génie informatique et de génie logiciel This work is licensed under a Creative Commons Attribution-NonCommercialShareAlike 3.0 Unported License
  2. 2. Patterns Patterns document reusable solutions to recurring problems – Architecture • Architectural styles – Design • Design patterns • Design anti-patterns – Implementation • Idioms 2/69
  3. 3. Patterns Several books, articles – “Theoretical” – With examples – Among others… 3/69
  4. 4. Patterns Several books, articles – “Theoretical” – With examples – Among others… 4/69
  5. 5. Patterns Several books, articles – “Theoretical” – With examples – Among others… 5/69
  6. 6. Patterns Several books, articles – “Theoretical” – With examples – Among others… 6/69
  7. 7. Patterns Several books, articles – “Theoretical” – With examples – Among others… 7/69
  8. 8. Patterns Several books, articles – “Theoretical” – With examples – Among others… 8/69
  9. 9. 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 how the design patterns actually function in the real world. Most programmers learn by looking at computer programs.” —Allen Holub in Holub on Patterns: Learning Design Patterns by Looking at Code 9/69
  10. 10. Outline Patterns Ptidej Tool Suite 10/69
  11. 11. Outline Patterns Ptidej Tool Suite 11/69
  12. 12. Patterns Several books, articles – Amazon.com • Books › Computers & Technology › Programming › Software Design, Testing & Engineering › ObjectOriented Design › "patterns" • 224 results on May 31, 2013 12/69
  13. 13. Patterns Several books, articles – Amazon.com • Exclusion – 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 13/69
  14. 14. Patterns 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 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 Pattern-Oriented Software Architecture, Patterns for Resource Management: Volume 3 (Wiley Software Patterns Series... by Michael Kircher and Prashant Jain Pattern-Oriented Software Architecture, A System of Patterns: Volume 1 (Wiley Software Patterns Series) by Frank Buschmann, Regine Meunier, Hans Rohnert and Peter Sommerlad Pattern-Oriented Software Architecture For Dummies (For Dummies (Computers)) by Robert Hanmer Web Security Patterns by Ramesh Nagappan and Christopher Steel Safe C++ by Vladimir Kushnir Programming in the Large with Design Patterns by Eddie Burris Elemental Design Patterns by Jason McC. Smith Java Application Architecture: Modularity Patterns with Examples Using OSGi (Robert C. Martin Series) by Kirk Knoernschild Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions (Addison-Wesley Signature... by Gregor Hohpe and Bobby Woolf Patterns of Enterprise Application Architecture (Addison-Wesley Signature Series (Fowler)) by Martin Fowler Cognitive Patterns: Problem-Solving Frameworks for Object Technology by Robert K Konitzer, Bobbin Teegarden, Alexander Rush and Karen M Gardner Service Design Patterns: Fundamental Design Solutions for SOAP/WSDL and RESTful Web Services by Robert Daigneau The ACE Programmer's Guide: Practical Design Patterns for Network and Systems Programming by Stephen D. Huston, James CE Johnson and Umar Syyid Patterns for Parallel Software Design (Wiley Software Patterns Series) by Jorge Luis Ortega-Arjona Design Patterns in Object-oriented ABAP by Igor Barbaric Object-Oriented Reengineering Patterns by Oscar Nierstrasz, Stéphane Ducasse and Serge Demeyer Dependency Injection by Dhanji R. Prasanna Object-Oriented Software Engineering Using UML, Patterns, and Java (3rd Edition) by Bernd Bruegge and Allen H. Dutoit J2EE Design Patterns by William Crawford and Jonathan Kaplan Applying UML and Patterns: An Introduction to Object-oriented Analysis and Design and Iterative Development by Craig Larman Object-oriented Analysis and Design Using Umlan Introduction to Unified Process and Design Patterns by Mahesh P. Matha C++ Design Patterns and Derivatives Pricing (Mathematics, Finance and Risk) by M. S. Joshi Effective Java (2nd Edition) by Joshua Bloch Patterns for Fault Tolerant Software (Wiley Software Patterns Series) by Robert Hanmer Implementation Patterns by Kent Beck Patterns for Computer-Mediated Interaction (Wiley Software Patterns Series) by Till Schummer and Stephan Lukosch Pattern Oriented Software Architecture Volume 5: On Patterns and Pattern Languages by Frank Buschmann, Kevlin Henney and Douglas C. Schmidt Object-Oriented Analysis and Design with Applications (3rd Edition) by Grady Booch, Robert A. Maksimchuk, Michael W. Engle and Bobbi J. Young Head First Object-Oriented Analysis and Design by Brett D. McLaughlin, Gary Pollice and Dave West Agile Principles, Patterns, and Practices in C# by Robert C. Martin and Micah Martin Design Patterns For Dummies by Steve Holzner Pattern Languages of Program Design 5 by Dragos Manolescu, Markus Voelter and James Noble Design Patterns in Java(TM) (Software Patterns Series) by Steven John Metsker and William C. Wake Object-Oriented Design and Patterns by Cay S. Horstmann 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. Object-Oriented Modeling and Design with UML (2nd Edition) by Michael R. Blaha and James R Rumbaugh Remoting Patterns: Foundations of Enterprise, Internet and Realtime Distributed Object Middleware (Wiley Software... by Markus Völter, Michael Kircher and Uwe Zdun Software Factories: Assembling Applications with Patterns, Models, Frameworks, and Tools (Wiley Application Development... by Jack Greenfield, Keith Short, Steve Cook and Stuart Kent Refactoring to Patterns by Joshua Kerievsky Architecting Enterprise Solutions: Patterns for High-Capability Internet-based Systems (Wiley Software Patterns... by Paul Dyson and Andrew Longshaw Enterprise Patterns and MDA: Building Better Software with Archetype Patterns and UML by Jim Arlow and Ila Neustadt Data Access Patterns: Database Interactions in Object-Oriented Applications by Clifton Nock Domain-Driven Design: Tackling Complexity in the Heart of Software by Eric Evans Pattern-Oriented Analysis and Design: Composing Patterns to Design Software Systems by Sherif M. Yacoub, Hany H. Ammar, Sherif Yacoub and Hany Ammar Java Extreme Programming Cookbook by Eric M. Burke and Brian M. Coyner J2EE Best Practices: Java Design Patterns, Automation, and Performance (Wiley Application Development Series) by Darren Broemmer Real-Time Design Patterns: Robust Scalable Architecture for Real-Time Systems by Bruce Powel Douglass Design Patterns Java¿ Workbook by Steven John Metsker EJB Design Patterns: Advanced Patterns, Processes, and Idioms by Floyd Marinescu Streamlined Object Modeling: Patterns, Rules, and Implementation by Jill Nicola, Mark Mayfield and Mike Abney Design Patterns Explained: A New Perspective on Object-Oriented Design by Alan Shalloway and James Trott Small Memory Software: Patterns for systems with limited memory (Software Patterns Series) by James Noble and Charles Weir AntiPatterns in Project Management by William J. Brown, Hays W. "Skip" McCormick III and Scott W. Thomas Pattern Languages of Program Design 4 (Software Patterns Series) by Brian Foote, Neil Harrison and Hans Rohnert Testing Object-Oriented Systems: Models, Patterns, and Tools by Robert V. Binder Design Patterns and Contracts by Jean-Marc Jezequel, Michel Train and Christine Mingins Object-Oriented Software Development Using Java: Principles, Patterns, and Frameworks (1/e) by Xiaoping Jia Refactoring: Improving the Design of Existing Code by Martin Fowler, Kent Beck, John Brant and William Opdyke More Process Patterns: Delivering Large-Scale Systems Using Object Technology (SIGS: Managing Object Technology... by Scott W. Ambler Pattern Hatching: Design Patterns Applied by John Vlissides AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J. Brown, Raphael C. Malveau, Hays W. "Skip" McCormick and Thomas J. Mowbray A Little Java, A Few Patterns (Language, Speech, & Communication) by Matthias Felleisen, Daniel P. Friedman and Ralph E. Johnson Pattern Languages of Program Design 3 (v. 3) by Robert C. Martin, Dirk Riehle and Frank Buschmann Object Models: Strategies, Patterns, and Applications (2nd Edition) by Peter Coad, David North and Mark Mayfield Analysis Patterns: Reusable Object Models by Martin Fowler Patterns of Software: Tales from the Software Community by Richard P. Gabriel Pattern Languages of Program Design 2 (v. 2) by John Vlissides, James O. Coplien and Norman L. Kerth Software Patterns by James Coplien Software Architecture: Perspectives on an Emerging Discipline by Mary Shaw and David Garlan Adaptive Object-Oriented Software: The Demeter Method with Propagation Patterns: The Demeter Method with Propagation... by Karl Lieberherr Pattern Languages of Program Design by James O. Coplien and Douglas C. Schmidt 14/69
  15. 15. Patterns The following is not a substitute to reading previous books and practicing 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!) 15/69
  16. 16. Patterns The following is not a substitute to reading these books and practicing 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!) 16/69
  17. 17. Patterns General form as for the GoF , also inspired by Coplien’s form – Name – Problem(s) – Solution – Consequences 17/69
  18. 18. Patterns General form as for the GoF, also inspired by Coplien’s form – Name – Problem(s) – Example(s) – Solution – Example(s) – Consequences – (Follow-up) 18/69
  19. 19. Patterns General form as for the GoF, also inspired by Coplien’s form – Name – Problem(s) – Example(s) – Solution – Example(s) – Consequences – (Follow-up) Problem: Solution: 19/69
  20. 20. Patterns General form as for the GoF, also inspired by Coplien’s form – Not formal – Room for interpretation – But… • UML-like class diagrams • UML-like sequence diagrams • Smalltalk / C++ example code 20/69
  21. 21. Outline Patterns Ptidej Tool Suite 21/69
  22. 22. Ptidej Tool Suite Context – Research work started since my Ph.D. thesis (2000–2003) – 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 22/69
  23. 23. Ptidej Tool Suite Requirements – Software tools • Support the analysis of the implementation, design, and architecture of object-oriented programs • Support the detection and introduction of patterns at the code, design, and architectural levels 23/69
  24. 24. Ptidej Tool Suite Analysis – Domain concepts • “quality of object-oriented” • “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” 24/69
  25. 25. Ptidej Tool Suite Analysis – Domain concepts • “quality of object-oriented” • “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” 25/69
  26. 26. Ptidej Tool Suite Constraint – Apply patterns/best practices (existing or new) when developing the tools • Architectural • Design • Implementation – Self-imposed but sensible • “Eating your own dog food” (http://www.urbandictionary.com/define.php? term=eating%20your%20own%20dog%20food) 26/69
  27. 27. Ptidej Tool Suite Related work – Various parsers (target languages) e.g., GCCXML – Various meta-model (sometimes implicit) • • • • Similar to UML meta-model (1997) Before OMG KDM (2003) Before Eclipse EMF (2004) Before OMG MOF (2006) – Various tools e.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) 27/69
  28. 28. Ptidej Tool Suite Related work ↑ Existing ☺ ↓ Too low-level e.g., GCCXML ↓ No “free” parsers e.g., UML meta-model ↓ Difficult to access / to use / to adapt e.g., Rigi 28/69
  29. 29. Ptidej Tool Suite Related work – Pierre Cointe’s team in 2000 at École des Mines de Nantes, France – Fertile ground • Hervé Albin-Amiot was already developing a metamodel to describe design patterns – “Idioms and patterns Java: application to code synthesis and detection” (Ph.D. in 2003) – PDL (Pattern Description Language) 29/69
  30. 30. Ptidej Tool Suite What to detect? In what to detect it? How to express it? 30/69
  31. 31. Ptidej Tool Suite “Great software is not built, it is grown” —Bill de hÓra in 97 Things Every Software Architect Should Know 31/69
  32. 32. Ptidej Tool Suite Design Patterns Models of OO programs PDL metamodel 32/69
  33. 33. Ptidej Tool Suite PDL meta-model 33/69
  34. 34. Ptidej Tool Suite + PDL meta-model Models of OO programs 34/69
  35. 35. Ptidej Tool Suite + = PDL meta-model Models of OO programs PADL meta-model 35/69
  36. 36. Ptidej Tool Suite PADL Pattern and Abstract-level Description Language 36/69
  37. 37. Ptidej Tool Suite PADL Creators C++, C#, Java, JavaScript? PADL Pattern and Abstract-level Description Language 37/69
  38. 38. Ptidej Tool Suite PADL Analyses • Binary Class Relationships • Systematic UML PADL Creators C++, C#, Java, JavaScript? PADL Pattern and Abstract-level Description Language 38/69
  39. 39. Ptidej Tool Suite PADL Generators XMI… PADL Analyses • Binary Class Relationships • Systematic UML PADL Creators C++, C#, Java, JavaScript? PADL Pattern and Abstract-level Description Language 39/69
  40. 40. Ptidej Tool Suite PADL Generators XMI… PADL Analyses • Binary Class Relationships • Systematic UML PADL Creators C++, C#, Java, JavaScript? PADL Serialisers DB4O, JOS… PADL Pattern and Abstract-level Description Language 40/69
  41. 41. Ptidej Tool Suite PADL Generators XMI… PADL Analyses • Binary Class Relationships • Systematic UML PADL Design Motifs Anti-patterns, code smells, and µ-patterns PADL Creators C++, C#, Java, JavaScript? PADL Serialisers DB4O, JOS… PADL Pattern and Abstract-level Description Language 41/69
  42. 42. Ptidej Tool Suite PADL Generators XMI… POM Primitives, Operations, Metrics PADL Analyses • Binary Class Relationships • Systematic UML PADL Design Motifs Anti-patterns, code smells, and µ-patterns PADL Creators C++, C#, Java, JavaScript? PADL Serialisers DB4O, JOS… PADL Pattern and Abstract-level Description Language 42/69
  43. 43. Ptidej Tool Suite (Ptidej Solver) Identification of design motifs PADL Generators XMI… POM Primitives, Operations, Metrics PADL Analyses • Binary Class Relationships • Systematic UML PADL Design Motifs Anti-patterns, code smells, and µ-patterns PADL Creators C++, C#, Java, JavaScript? PADL Serialisers DB4O, JOS… PADL Pattern and Abstract-level Description Language 43/69
  44. 44. Ptidej Tool Suite (Ptidej Solver) Identification of design motifs SAD Identification of anti-patterns PADL Generators XMI… POM Primitives, Operations, Metrics PADL Analyses • Binary Class Relationships • Systematic UML PADL Design Motifs Anti-patterns, code smells, and µ-patterns PADL Creators C++, C#, Java, JavaScript? PADL Serialisers DB4O, JOS… PADL Pattern and Abstract-level Description Language 44/69
  45. 45. Ptidej Tool Suite Ptidej UI User interface (using reflection) (Ptidej Solver) Identification of design motifs SAD Identification of anti-patterns PADL Generators XMI… POM Primitives, Operations, Metrics PADL Analyses • Binary Class Relationships • Systematic UML PADL Design Motifs Anti-patterns, code smells, and µ-patterns PADL Creators C++, C#, Java, JavaScript? PADL Serialisers DB4O, JOS… PADL Pattern and Abstract-level Description Language 45/69
  46. 46. Ptidej UI Viewer Standalone Swing displaying PADL (Another example of “Eating your own dog food” ☺) 46/69
  47. 47. PADL Kernel, main interfaces provided to the users (SVG and JPG from Ptidej UI Viewer Standalone Swing) 47/69
  48. 48. PADL Kernel, abstract-level models Describe models of programs, including design motifs 48/69
  49. 49. PADL Kernel, elements Describe methods, fields… 49/69
  50. 50. PADL Kernel, entities Describe classes, interfaces… 50/69
  51. 51. PADL Kernel, relationships Describe inheritances, associations… 51/69
  52. 52. Ptidej Tool Suite Advantages – Creators – BCRs – Extensibility – Reliability (Has been used in many studies) 52/69
  53. 53. Ptidej Tool Suite Advantages – Available! ☺ • https://web.soccerlab.polymtl.ca/rptidej/ptidejlab/ 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 53/69
  54. 54. Ptidej Tool Suite Advantages – Extensible e.g., C++ creator provide new/modified constituent • Factory design pattern • Builder design pattern – Including for the user interface 54/69
  55. 55. Ptidej Tool Suite Limits – Coarse representation of method statements – Unsatisfactory support of non-typed, non-objectoriented programming languages • (Very) partial support for Smalltalk 55/69
  56. 56. Ptidej Tool Suite Performance – Eclipse v3.1 – Google Chrome v1.0.154.53 • Quality of the model under tests 56/69
  57. 57. 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 Approximate Diagram Matching for Design Comparison. IEEE TSE, Feburary 2013 – Please see • http://www.ptidej.net/publications/ 57/69
  58. 58. Ptidej Tool Suite Concrete Usage – Build a model from some C++ code (1/2) public static IIdiomLevelModel generateModelFromCppFilesUsingEclipse( final String aName, 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()); } ... 58/69
  59. 59. Specialised creator Ptidej Tool Suite Concrete Usage – Build a model from some C++ code (1/2) public static IIdiomLevelModel generateModelFromCppFilesUsingEclipse( final String aName, 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()); } ... 59/69
  60. 60. Specialised creator Ptidej Tool Suite Concrete Usage Specialised factory to allow new constituents – Build a model from some C++ code (1/2) public static IIdiomLevelModel generateModelFromCppFilesUsingEclipse( final String aName, 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()); } ... 60/69
  61. 61. Specialised creator Ptidej Tool Suite Concrete Usage Specialised factory to allow new constituents Builder design pattern – Build a model from some C++ code (1/2) public static IIdiomLevelModel generateModelFromCppFilesUsingEclipse( final String aName, 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()); } ... 61/69
  62. 62. Ptidej Tool Suite Concrete Usage – Build a model from some C++ code (2/2) public static IIdiomLevelModel generateModelFromCppFilesUsingEclipse( final String aName, 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; } 62/69
  63. 63. Promotion of the model Ptidej Tool Suite Concrete Usage – Build a model from some C++ code (2/2) public static IIdiomLevelModel generateModelFromCppFilesUsingEclipse( final String aName, 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; } 63/69
  64. 64. Ptidej Tool Suite Concrete Usage – Identify occurrence of the Composite DM final Problem problem = CompositeMotif.getProblem(Manager.build(idiomLevelModel)); 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); 64/69
  65. 65. Ptidej Tool Suite From a library of design motifs Concrete Usage – Identify occurrence of the Composite DM final Problem problem = CompositeMotif.getProblem(Manager.build(idiomLevelModel)); 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); 65/69
  66. 66. Ptidej Tool Suite Concrete Usage – Identify occurrence of the Blob anti-pattern final IDesignSmellDetection detection = (IDesignSmellDetection) new BlobDetection(); detection.setMetricsFileRepository(ClassFileRepository.getInstance(Repository.class)); 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); 66/69
  67. 67. Ptidej Tool Suite From a library of anti-patterns Concrete Usage – Identify occurrence of the Blob anti-pattern final IDesignSmellDetection detection = (IDesignSmellDetection) new BlobDetection(); detection.setMetricsFileRepository(ClassFileRepository.getInstance(Repository.class)); 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); 67/69
  68. 68. Ptidej Tool Suite Limitations and future work – Treatment and modelling of method bodies • Coarse grain multi-language support for method bodies currently available • Fine grain through meta-model extension – Treatment and modelling of non-typed, nonobject-oriented programming languages • Unsatisfactory support for Smalltalk • No support for PHP, JavaScript 68/69
  69. 69. Ptidej Tool Suite Limitations and future work – Treatment and modelling of method bodies • Coarse grain multi-language support for method bodies currently available • Fine grain through meta-model extension – Treatment and modelling of non-typed, nonobject-oriented programming languages • Unsatisfactory support for Smalltalk • No support for PHP, JavaScript 69/69

×