Advertisement

Recommending Program Transformations

Automating Repetitive Software Changes
  • Miryung Kim
  • Na Meng
Chapter

Abstract

Adding features and fixing bugs in software often require systematic edits which are similar but not identical changes to multiple code locations. Finding all relevant locations and making the correct edits is a tedious and error-prone process. This chapter presents several state-of-the art approaches to recommending program transformation in order to automate repetitive software changes. First, it discusses programming-by-demonstration (PBD) approaches that automate repetitive tasks by inferring a generalized action script from a user’s recorded actions. Second, it presents edit location suggestion approaches that only recommend candidate edit locations but do not apply necessary code transformations. Finally, it describes program transformation approaches that take code examples or version histories as input, automatically identify candidate edit locations, and apply context awareness, customization program transformations to generate a new program version. In particular, this chapter describes two concrete example-based program transformation approaches in detail, Sydit and Lase. These two approaches are selected for an in-depth discussion, because they handle the issue of both recommending change locations and applying transformations, and they are specifically designed to update programs as opposed to regular text documents. The chapter is then concluded with open issues and challenges of recommending program transformations.

Keywords

Application Programming Interface Edit Operation Program Transformation Code Change Code Transformation 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Notes

Acknowledgments

We thank Kathryn McKinley who contributed to designing and evaluating key algorithms of Sydit and Lase. We also thank her for our fruitful collaboration and numerous discussions on example-based program transformation approaches. We thank John Jacobellis who is a main contributor of developing the Lase Eclipse plugin. This work was supported in part by the National Science Foundation under grants CCF-1149391, CCF-1117902, SHF-0910818, and CCF-0811524 and by a Microsoft SEIF award.

References

  1. 1.
    Andersen, J.: Semantic patch inference. Ph.D. thesis, University of Copenhagen (2009)Google Scholar
  2. 2.
    Andersen, J., Lawall, J.L.: Generic patch inference. In: Proceedings of the IEEE/ACM International Conference on Automated Software Engineering, pp. 337–346 (2008). doi:10.1109/ASE.2008.44Google Scholar
  3. 3.
    Baxter, I.D., Pidgeon, C., Mehlich, M.: DMS: program transformations for practical scalable software evolution. In: Proceedings of the ACM/IEEE International Conference on Software Engineering, pp. 625–634 (2004). doi:10.1109/ICSE.2004.1317484Google Scholar
  4. 4.
    Boshernitsan, M., Graham, S.L., Hearst, M.A.: Aligning development tools with the way programmers think about code changes. In: Proceedings of the ACM SIGCHI Conference on Human Factors in Computing Systems, pp. 567–576 (2007). doi:10.1145/1240624.1240715Google Scholar
  5. 5.
    Breu, S., Zimmermann, T.: Mining aspects from version history. In: Proceedings of the IEEE/ACM International Conference on Automated Software Engineering, pp. 221–230 (2006). doi:10.1109/ASE.2006.50Google Scholar
  6. 6.
    Canfora, G., Cerulo, L., Cimitile, M., Di Penta, M.: Social interactions around cross-system bug fixings: the case of FreeBSD and OpenBSD. In: Proceedings of the International Working Conference on Mining Software Repositories, pp. 143–152 (2011). doi:10.1145/1985441.1985463Google Scholar
  7. 7.
    Castro, S., Brichau, J., Mens, K.: Diagnosis and semi-automatic correction of detected design inconsistencies in source code. In: Proceedings of the International Workshop on Smalltalk Technologies, pp. 8–17 (2009). doi:10.1145/1735935.1735938Google Scholar
  8. 8.
    Cordy, J.R.: The TXL source transformation language. Sci. Comput. Program. 61(3), 190–210 (2006). doi:10.1016/j.scico.2006.04.002CrossRefzbMATHMathSciNetGoogle Scholar
  9. 9.
    De Volder, K.: JQuery: a generic code browser with a declarative configuration language. In: Hentenryck, P. (ed.) Practical Aspects of Declarative Languages. Lecture Notes in Computer Science, vol. 3819, pp. 88–102. Springer, Heidelberg (2006). doi:10.1007/11603023_7CrossRefGoogle Scholar
  10. 10.
    Duala-Ekoko, E., Robillard, M.P.: Clone region descriptors: representing and tracking duplication in source code. ACM T. Software Eng. Meth. 20(1), 3:1–3:31 (2010). doi:10.1145/1767751.1767754Google Scholar
  11. 11.
    Eaddy, M., Zimmermann, T., Sherwood, K.D., Garg, V., Murphy, G.C., Nagappan, N., Aho, A.V.: Do crosscutting concerns cause defects? IEEE T. Software Eng. 34(4), 497–515 (2008). doi:10.1109/TSE.2008.36CrossRefGoogle Scholar
  12. 12.
    Fluri, B., Würsch, M., Pinzger, M., Gall, H.C.: Change distilling: tree differencing for fine-grained source code change extraction. IEEE T. Software Eng. 33(11), 725–743 (2007). doi:10.1109/TSE.2007.70731CrossRefGoogle Scholar
  13. 13.
    Gulwani, S.: Dimensions in program synthesis. In: Proceedings of the ACM SIGPLAN International Symposium on Principles and Practice of Declarative Programming, pp. 13–24 (2010). doi:10.1145/1836089.1836091Google Scholar
  14. 14.
    Gulwani, S.: Automating string processing in spreadsheets using input–output examples. In: Proceedings of the ACM SIGPLAN Conference on Principles of Programming Languages, pp. 317–330 (2011). http://doi.acm.org/10.1145/1926385.1926423
  15. 15.
    Gulwani, S., Korthikanti, V.A., Tiwari, A.: Synthesizing geometry constructions. In: Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pp. 50–61 (2011). http://doi.acm.org/10.1145/1993498.1993505
  16. 16.
    Harris, W.R., Gulwani, S.: Spreadsheet table transformations from examples. In: Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pp. 317–328 (2011). doi:10.1145/1993498.1993536Google Scholar
  17. 17.
    Henkel, J., Diwan, A.: CatchUp!: capturing and replaying refactorings to support API evolution. In: Proceedings of the ACM/IEEE International Conference on Software Engineering, pp. 274–283 (2005). doi:10.1145/1062455.1062512Google Scholar
  18. 18.
    Jacobellis, J., Meng, N., Kim, M.: LASE: an example-based program transformation tool for locating and applying systematic edits. In: Proceedings of the ACM/IEEE International Conference on Software Engineering, pp. 1319–1322 (2013). doi:10.1109/ICSE.2013.6606707Google Scholar
  19. 19.
    Kapur, P., Cossette, B., Walker, R.J.: Refactoring references for library migration. In: Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pp. 726–738 (2010). doi:10.1145/1869459.1869518Google Scholar
  20. 20.
    Kellens, A., Mens, K., Tonella, P.: A survey of automated code-level aspect mining techniques. In: Rashid, A., Aksit, M. (eds.) Transactions on Aspect-Oriented Software Development IV. Lecture Notes in Computer Science, vol. 4640, pp. 143–162. Springer, Heidelberg (2007). doi:10.1007/978-3-540-77042-8_6CrossRefGoogle Scholar
  21. 21.
    Kiczales, G., Lamping, J., Menhdhekar, A., Maeda, C., Lopes, C., Loingtier, J.M., Irwin, J.: Aspect-oriented programming. In: Proceedings of the European Conference on Object-Oriented Programming. Lecture Notes in Computer Science, vol. 1241, pp. 220–242 (1997). doi:10.1007/BFb0053381Google Scholar
  22. 22.
    Kim, M., Cai, D., Kim, S.: An empirical investigation into the role of API-level refactorings during software evolution. In: Proceedings of the ACM/IEEE International Conference on Software Engineering, pp. 151–160 (2011). doi:10.1145/1985793.1985815Google Scholar
  23. 23.
    Kim, M., Notkin, D.: Discovering and representing systematic code changes. In: Proceedings of the ACM/IEEE International Conference on Software Engineering, pp. 309–319 (2009). doi:10.1109/ICSE.2009.5070531Google Scholar
  24. 24.
    Kim, M., Sazawal, V., Notkin, D., Murphy, G.: An empirical study of code clone genealogies. In: Proceedings of the European Software Engineering Conference/ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 187–196 (2005). doi:10.1145/1081706.1081737Google Scholar
  25. 25.
    Kim, M., Zimmermann, T., Nagappan, N.: A field study of refactoring challenges and benefits. In: Proceedings of the ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 50:1–50:11 (2012). doi:10.1145/2393596.2393655Google Scholar
  26. 26.
    Kim, S., Pan, K., Whitehead Jr., E.E.J.: Memories of bug fixes. In: Proceedings of the ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 35–45 (2006). doi:10.1145/1181775.1181781Google Scholar
  27. 27.
    Landauer, J., Hirakawa, M.: Visual AWK: a model for text processing by demonstration. In: Proceedings of the IEEE International Symposium on Visual Languages, pp. 267–274 (1995). doi:10.1109/VL.1995.520818Google Scholar
  28. 28.
    Lau, T., Wolfman, S.A., Domingos, P., Weld, D.S.: Learning repetitive text-editing procedures with SMARTedit. In: Lieberman, H. (ed.) Your Wish is My Command: Programming by Example, pp. 209–226. Morgan Kaufmann, Los Altos, CA (2001)CrossRefGoogle Scholar
  29. 29.
    Li, Z., Zhou, Y.: PR-Miner: automatically extracting implicit programming rules and detecting violations in large software code. In: Proceedings of the European Software Engineering Conference/ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 306–315 (2005). doi:10.1145/1081706.1081755Google Scholar
  30. 30.
    Lieberman, H. (ed.): Your Wish Is My Command: Programming by Example. Morgan Kaufmann, Los Altos, CA (2001)Google Scholar
  31. 31.
    Martin, M., Livshits, B., Lam, M.S.: Finding application errors and security flaws using PQL: a program query language. In: Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pp. 365–383 (2005). doi:10.1145/1094811.1094840Google Scholar
  32. 32.
    Masui, T., Nakayama, K.: Repeat and predict: two keys to efficient text editing. In: Proceedings of the ACM SIGCHI Conference on Human Factors in Computing Systems, pp. 118–130 (1994). doi:10.1145/191666.191722Google Scholar
  33. 33.
    Maulsby, D., Witten, I.H.: Cima: an interactive concept learning system for end-user applications. Appl. Artif. Intell.: Int. J. 11(7–8), 653–671 (1997). doi:10.1080/088395197117975CrossRefGoogle Scholar
  34. 34.
    McIntyre, M., Walker, R.J.: Assisting potentially-repetitive small-scale changes via semi-automated heuristic search. In: Proceedings of the IEEE/ACM International Conference on Automated Software Engineering, pp. 497–500 (2007). doi:10.1145/1321631.1321718Google Scholar
  35. 35.
    McIntyre, M.: Supporting repetitive small-scale changes. MSc thesis, University of Calgary (2007)Google Scholar
  36. 36.
    Meng, N., Kim, M., McKinley, K.S.: Sydit: creating and applying a program transformation from an example. In: Proceedings of the European Software Engineering Conference/ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 440–443 (2011a). doi:10.1145/2025113.2025185Google Scholar
  37. 37.
    Meng, N., Kim, M., McKinley, K.S.: Systematic editing: generating program transformations from an example. In: Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pp. 329–342 (2011b). doi:10.1145/1993498.1993537Google Scholar
  38. 38.
    Meng, N., Kim, M., McKinley, K.S.: LASE: locating and applying systematic edits by learning from examples. In: Proceedings of the ACM/IEEE International Conference on Software Engineering, pp. 502–511 (2013). doi:10.1109/ICSE.2013.6606596Google Scholar
  39. 39.
    Mens, K., Lozano, A.: Source code based recommendation systems. In: Robillard, M., Maalej, W., Walker, R.J., Zimmermann, T. (eds.) Recommendation Systems in Software Engineering. Springer, Heidelberg, Chap.  5. (2014)
  40. 40.
    Mens, K., Wuyts, R., D’Hondt, T.: Declaratively codifying software architectures using virtual software classifications. In: Proceedings of the International Conference on Technology of Object-Oriented Languages and Systems, pp. 33–45 (1999). doi:10.1109/TOOLS.1999.778997Google Scholar
  41. 41.
    Miller, R.C., Myers, B.A.: Interactive simultaneous editing of multiple text regions. In: Proceedings of the USENIX Annual Technical Conference, pp. 161–174 (2001)Google Scholar
  42. 42.
    Muşlu, K., Brun, Y., Holmes, R., Ernst, M.D., Notkin, D.: Speculative analysis of integrated development environment recommendations. In: Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pp. 669–682 (2012). doi:10.1145/2384616.2384665Google Scholar
  43. 43.
    Murphy-Hill, E., Parnin, C., Black, A.P.: How we refactor, and how we know it. IEEE T. Software Eng. 38(1), 5–18 (2011). doi:10.1109/TSE.2011.41CrossRefGoogle Scholar
  44. 44.
    Nguyen, H.A., Nguyen, T.T., Wilson Jr., G., Nguyen, A.T., Kim, M., Nguyen, T.N.: A graph-based approach to API usage adaptation. In: Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pp. 302–321 (2010a). doi:10.1145/1869459.1869486Google Scholar
  45. 45.
    Nguyen, T.T., Nguyen, H.A., Pham, N.H., Al-Kofahi, J., Nguyen, T.N.: Recurring bug fixes in object-oriented programs. In: Proceedings of the ACM/IEEE International Conference on Software Engineering, pp. 315–324 (2010b). doi:10.1145/1806799.1806847Google Scholar
  46. 46.
    Nguyen, T.T., Nguyen, H.A., Pham, N.H., Al-Kofahi, J.M., Nguyen, T.N.: Clone-aware configuration management. In: Proceedings of the IEEE/ACM International Conference on Automated Software Engineering, pp. 123–134 (2009). doi:10.1109/ASE.2009.90Google Scholar
  47. 47.
    Nix, R.: Editing by example. In: Proceedings of the ACM SIGPLAN Conference on Principles of Programming Languages, pp. 186–195 (1984). doi:10.1145/800017.800530Google Scholar
  48. 48.
    Padioleau, Y., Lawall, J., Hansen, R.R., Muller, G.: Documenting and automating collateral evolutions in Linux device drivers. In: Proceedings of the ACM SIGOPS/EuroSys European Conference on Computer Systems, pp. 247–260 (2008). doi:10.1145/1352592.1352618Google Scholar
  49. 49.
    Park, J., Kim, M., Ray, B., Bae, D.H.: An empirical study of supplementary bug fixes. In: Proceedings of the International Working Conference on Mining Software Repositories, pp. 40–49 (2012). doi:10.1109/MSR.2012.6224298Google Scholar
  50. 50.
    Perkins, J.H., Kim, S., Larsen, S., Amarasinghe, S., Bachrach, J., Carbin, M., Pacheco, C., Sherwood, F., Sidiroglou, S., Sullivan, G., Wong, W.F., Zibin, Y., Ernst, M.D., Rinard, M.: Automatically patching errors in deployed software. In: Proceedings of the ACM Symposium on Operating Systems Principles, pp. 87–102 (2009). doi:10.1145/1629575.1629585Google Scholar
  51. 51.
    Person, S., Dwyer, M.B., Elbaum, S., Păsăreanu, C.S.: Differential symbolic execution. In: Proceedings of the ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 226–237 (2008). doi:10.1145/1453101.1453131Google Scholar
  52. 52.
    Pollock, L.: Leveraging natural language analysis of software: achievements, challenges, and opportunities. In: Proceedings of the IEEE International Conference on Software Maintenance, p. 4 (2012). doi:10.1109/ICSM.2012.6405245Google Scholar
  53. 53.
    Purushothaman, R., Perry, D.E.: Toward understanding the rhetoric of small source code changes. IEEE T. Software Eng. 31(6), 511–526 (2005). doi:10.1109/TSE.2005.74CrossRefGoogle Scholar
  54. 54.
    Ray, B., Kim, M.: A case study of cross-system porting in forked projects. In: Proceedings of the European Software Engineering Conference/ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 53:1–53:11 (2012). doi:10.1145/2393596.2393659Google Scholar
  55. 55.
    Robbes, R., Lanza, M.: Example-based program transformation. In: Proceedings of the International Conference on Model-Driven Engineering of Languages and Systems. Lecture Notes in Computer Science, vol. 5301, pp. 174–188 (2008). doi:10.1007/978-3-540-87875-9_13Google Scholar
  56. 56.
    Schaefer, M., de Moor, O.: Specifying and implementing refactorings. In: Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pp. 286–301 (2010). doi:10.1145/1869459.1869485Google Scholar
  57. 57.
    Shepherd, D., Fry, Z.P., Hill, E., Pollock, L., Vijay-Shanker, K.: Using natural language program analysis to locate and understand action-oriented concerns. In: Proceedings of the International Conference on Aspect-Oriented Software Deveopment, pp. 212–224 (2007). doi:10.1145/1218563.1218587Google Scholar
  58. 58.
    Solar-Lezama, A., Arnold, G., Tancau, L., Bodik, R., Saraswat, V., Seshia, S.: Sketching stencils. In: Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pp. 167–178 (2007). doi:10.1145/1250734.1250754Google Scholar
  59. 59.
    Tarr, P., Ossher, H., Harrison, W., Stanley M. Sutton, J.: N degrees of separation: multi-dimensional separation of concerns. In: Proceedings of the ACM/IEEE International Conference on Software Engineering, pp. 107–119 (1999). doi:10.1145/302405.302457Google Scholar
  60. 60.
    Toomim, M., Begel, A., Graham, S.L.: Managing duplicated code with linked editing. In: Proceedings of the IEEE Symposium on Visual Languages and Human-Centric Computing, pp. 173–180 (2004). http://dx.doi.org/10.1109/VLHCC.2004.35
  61. 61.
    Walker, R.J., Holmes, R.: Simulation: a methodology to evaluate recommendation systems in software engineering. In: Robillard, M., Maalej, W., Walker, R.J., Zimmermann, T. (eds.) Recommendation Systems in Software Engineering. Springer, Heidelberg, Chap.  12. (2014)
  62. 62.
    Wang, X., Lo, D., Cheng, J., Zhang, L., Mei, H., Yu, J.X.: Matching dependence-related queries in the system dependence graph. In: Proceedings of the IEEE/ACM International Conference on Automated Software Engineering, pp. 457–466 (2010). doi:10.1145/1858996.1859091Google Scholar
  63. 63.
    Weimer, W., Nguyen, T., Le Goues, C., Forrest, S.: Automatically finding patches using genetic programming. In: Proceedings of the ACM/IEEE International Conference on Software Engineering, pp. 364–374 (2009). doi:10.1109/ICSE.2009.5070536Google Scholar
  64. 64.
    Weißgerber, P., Diehl, S.: Are refactorings less error-prone than other changes? In: Proceedings of the International Workshop on Mining Software Repositories, pp. 112–118 (2006). doi:10.1145/1137983.1138011Google Scholar
  65. 65.
    Witten, I.H., Mo, D.: TELS: Learning Text Editing Tasks from Examples, pp. 183–203. MIT, Cambridge, MA (1993)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2014

Authors and Affiliations

  1. 1.The University of Texas at AustinAustinUSA

Personalised recommendations