System Specific, Source Code Transformations (ICSME 2015)

688ae0c04598b774dfb4f2b8b794fc57?s=47 gustavojss
September 30, 2015

System Specific, Source Code Transformations (ICSME 2015)

During its lifetime, a software system might undergo a major transformation effort in its structure, for example to migrate to a new architecture or bring some drastic improvements to the system. Particularly in this context, we found evidences that some sequences of code changes are made in a systematic way. These sequences are composed of small code transformations (e.g., create a class, move a method) which are repeatedly applied to groups of related entities (e.g., a class and some of its methods). We define these sequences as transformation patterns. In this work, we identify examples of transformation patterns in real world software systems and study their properties: (i) they are specific to a system; (ii) they were applied manually; (iii) they were not always applied to all the software entities which could have been transformed; (iv) they were sometimes complex; and (v) they were not always applied in one shot but over several releases. These results suggest that transformation patterns could benefit from automated support in their application.

688ae0c04598b774dfb4f2b8b794fc57?s=128

gustavojss

September 30, 2015
Tweet

Transcript

  1. System Specific, Source Code Transformations Gustavo Santos, Nicolas Anquetil, Anne

    Etien, Stéphane Ducasse, and Marco Tulio Valente
  2. Systematic Code Transformation JHotDraw 7.4.1 → 7.5.1 2

  3. Systematic Code Transformation JHotDraw 7.4.1 → 7.5.1 2 class HSLColorSpace

    extends ColorSpace { public HSLColorSpace() { /* … */ } // … } class HSLColorSpace extends ColorSpace implements NamedColorSpace { private static HSLColorSpace instance; public static HSLColorSpace getInstance() { /* … */ } private HSLColorSpace() { /* … */ } public String getName() { return “HSL”; } // … }
  4. Systematic Code Transformation JHotDraw 7.4.1 → 7.5.1 3 class HSVColorSpace

    extends ColorSpace { public HSVColorSpace() { /* … */ } // … } class HSVColorSpace extends ColorSpace implements NamedColorSpace { private static HSVColorSpace instance; public static HSVColorSpace getInstance() { /* … */ } private HSVColorSpace() { /* … */ } public String getName() { return “HSV”; } // … }
  5. Systematic Code Transformation JHotDraw 7.4.1 → 7.5.1 3 Applied 9

    times class HSVColorSpace extends ColorSpace { public HSVColorSpace() { /* … */ } // … } class HSVColorSpace extends ColorSpace implements NamedColorSpace { private static HSVColorSpace instance; public static HSVColorSpace getInstance() { /* … */ } private HSVColorSpace() { /* … */ } public String getName() { return “HSV”; } // … }
  6. Problem Complex Tedious Error-prone 4

  7. Changes Operators Change Operators [Jav2012] 5

  8. Changes Operators Change Operators [Jav2012] 5 class HSVColorSpace extends ColorSpace

    implements NamedColorSpace { private static HSVColorSpace instance; public static HSVColorSpace getInstance() { /* … */ } private HSVColorSpace() { /* … */ } public String getName() { return “HSV”; } // … } class HSVColorSpace implements NamedColorSpace add static attribute instance add static method getInstance set visibility to private add method getName
  9. Changes Operators Change Operators [Jav2012] 5 class HSVColorSpace extends ColorSpace

    implements NamedColorSpace { private static HSVColorSpace instance; public static HSVColorSpace getInstance() { /* … */ } private HSVColorSpace() { /* … */ } public String getName() { return “HSV”; } // … } class HSVColorSpace implements NamedColorSpace add static attribute instance add static method getInstance set visibility to private add method getName Atomic and generic
  10. Changes Operators Change Operators [Jav2012] 5 class HSVColorSpace extends ColorSpace

    implements NamedColorSpace { private static HSVColorSpace instance; public static HSVColorSpace getInstance() { /* … */ } private HSVColorSpace() { /* … */ } public String getName() { return “HSV”; } // … } class HSVColorSpace implements NamedColorSpace add static attribute instance add static method getInstance set visibility to private add method getName Atomic and generic Aggregated, still generic
  11. Changes Operators Change Operators [Jav2012] 5 class HSVColorSpace extends ColorSpace

    implements NamedColorSpace { private static HSVColorSpace instance; public static HSVColorSpace getInstance() { /* … */ } private HSVColorSpace() { /* … */ } public String getName() { return “HSV”; } // … } class HSVColorSpace implements NamedColorSpace add static attribute instance add static method getInstance set visibility to private add method getName Atomic and generic Aggregated, still generic Aggregated, but system specific
  12. Express an abstract representation of operators 6

  13. Express an abstract representation of operators class C implements NamedColorSpace

    add static attribute named instance in C add static method named getInstance in C set visibility of C() to private add method named getName in C 6
  14. Express an abstract representation of operators class C implements NamedColorSpace

    add static attribute named instance in C add static method named getInstance in C set visibility of C() to private add method named getName in C 6 for each class C extending ColorSpace class C implements NamedColorSpace add static attribute named instance in C add static method named getInstance in C set visibility of C() to private add method named getName in C
  15. Express an abstract representation of operators class C implements NamedColorSpace

    add static attribute named instance in C add static method named getInstance in C set visibility of C() to private add method named getName in C 6 for each class C extending ColorSpace class C implements NamedColorSpace add static attribute named instance in C add static method named getInstance in C set visibility of C() to private add method named getName in C Transformation Operator
  16. Express an abstract representation of operators class C implements NamedColorSpace

    add static attribute named instance in C add static method named getInstance in C set visibility of C() to private add method named getName in C 6 for each class C extending ColorSpace class C implements NamedColorSpace add static attribute named instance in C add static method named getInstance in C set visibility of C() to private add method named getName in C Transformation Operator Application Condition
  17. Express an abstract representation of operators class C implements NamedColorSpace

    add static attribute named instance in C add static method named getInstance in C set visibility of C() to private add method named getName in C Transformation Pattern 6 for each class C extending ColorSpace class C implements NamedColorSpace add static attribute named instance in C add static method named getInstance in C set visibility of C() to private add method named getName in C Transformation Operator Application Condition
  18. Evaluation Goal: Motivate the automation of transformation patterns Find other

    instances in different systems 7
  19. Rearchitecting [Avg2013] Substantial effort Changes the entire system 8

  20. Evaluation Methodology Systems under rearchitecting in the past [San2014] We

    have the source code before and after the changes Compute the changes (e.g., Eclipse diff) Search for similar changes semi-automatically Identify the application condition 9
  21. RQ1 Can we identify instances of transformation patterns in other

    systems? 10
  22. RQ1 Can we identify instances of transformation patterns in other

    systems? 10 Occurrences Eclipse I 26 Eclipse II 72 JHotDraw 9 MyWebMarket 7 VerveineJ 3 PetitDelphi 19 PetitSQL 6 PackageManager I 66 PackageManager II 19 PackageManager III 64 PackageManager IV 7 Telescope — GeneticAlgorithms — Average 27
  23. RQ2 Are transformation patterns applied to all the transformation opportunities?

    11
  24. RQ2 Are transformation patterns applied to all the transformation opportunities?

    11 Entities matching condition Occurrences Eclipse I 34 26 Eclipse II 86 70 JHotDraw 9 9 MyWebMarket 7 7 VerveineJ 3 3 PetitDelphi 19 15 PetitSQL 6 6 PackageManager I 66 66 PackageManager II 19 19 PackageManager III 64 64 PackageManager IV 7 7 Average 27
  25. RQ3 12

  26. RQ3 Are all the transformation operators in the transformation patterns

    applied to all the opportunities? 12
  27. RQ3 Are all the transformation operators in the transformation patterns

    applied to all the opportunities? JHotDraw 7.4.1 → 7.5.1 12 Applied 9 times
  28. RQ3 Are all the transformation operators in the transformation patterns

    applied to all the opportunities? JHotDraw 7.4.1 → 7.5.1 12 class HSBColorSpace extends ColorSpace implements NamedColorSpace { private static HSBColorSpace instance; public static HSBColorSpace getInstance() { /* … */ } public HSLColorSpace() { /* … */ } public String getName() { return “HSB”; } // … } Applied 9 times 3 times
  29. RQ3 Are all the transformation operators in the transformation patterns

    applied to all the opportunities? JHotDraw 7.4.1 → 7.5.1 12 class HSBColorSpace extends ColorSpace implements NamedColorSpace { private static HSBColorSpace instance; public static HSBColorSpace getInstance() { /* … */ } public HSLColorSpace() { /* … */ } public String getName() { return “HSB”; } // … } class CIELCHabColorSpace extends ColorSpace implements NamedColorSpace { public CIELCHabColorSpace() { /* … */ } public String getName() { return “CIE 1976 L*CHa*b*”; } // … } Applied 9 times 3 times 2 times
  30. RQ4 Are transformation patterns applied over several revisions? 13

  31. RQ4 Are transformation patterns applied over several revisions? 13 Revision

    Occurrences Eclipse II 3.0 70 3.1 71 3.2 72 PetitDelphi 210 15 211 17 212 18 213 19
  32. Conclusions Developers sometimes perform changes systematically We found examples of

    transformation patterns in real software systems Developers missed transformation opportunities Automation of composite transformations is needed. 14
  33. Recent Work [as presented on SCAM] 15

  34. Recent Work [as presented on SCAM] 15 configure new location

  35. Recent Work [as presented on SCAM] 15 configure new location

    Replay
  36. Recent Work [as presented on SCAM] 15 configure new location

    Replay Inspect and apply changes
  37. System Specific, Source Code Transformations Gustavo Santos, Nicolas Anquetil, Anne

    Etien, Stéphane Ducasse, and Marco Tulio Valente http://gustavojss.github.io/