Abstract
Matlab is a very popular dynamic “scripting” language for numerical computations used by scientists, engineers and students world-wide. Matlab programs are often developed incrementally using a mixture of Matlab scripts and functions, and frequently build upon existing code which may use outdated features. This results in programs that could benefit from refactoring, especially if the code will be reused and/or distributed. Despite the need for refactoring, there appear to be no Matlab refactoring tools available. Furthermore, correct refactoring of Matlab is quite challenging because of its non-standard rules for binding identifiers. Even simple refactorings are non-trivial.
This paper presents the important challenges of refactoring Matlab along with automated techniques to handle a collection of refactorings for Matlab functions and scripts including: converting scripts to functions, extracting functions, and converting dynamic function calls to static ones. The refactorings have been implemented using the McLab compiler framework, and an evaluation is given on a large set of Matlab benchmarks which demonstrates the effectiveness of our approach.
Chapter PDF
Similar content being viewed by others
Keywords
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.
References
Opdyke, W.F.: Refactoring Object-Oriented Frameworks. Ph.D. thesis, University of Illinois at Urbana-Champaign (1992)
Griswold, W.G.: Program Restructuring as an Aid to Software Maintenance. Ph.D. thesis, University of Washington (1991)
Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley (1999)
Doherty, J., Hendren, L., Radpour, S.: Kind analysis for MATLAB. In: Proceedings of OOPSLA 2011 (2011)
Lameed, N., Hendren, L.: Staged Static Techniques to Efficiently Implement Array Copy Semantics in a MATLAB JIT Compiler. In: Knoop, J. (ed.) CC 2011. LNCS, vol. 6601, pp. 22–41. Springer, Heidelberg (2011)
English, M., McCreanor, P.: Exploring the Differing Usages of Programming Language Features in Systems Developed in C++ and Java. In: PPIG (2009)
Radpour, S.: Understanding and Refactoring the Matlab Language. M.Sc. thesis, McGill University (2012)
Soares, G., Gheyi, R., Serey, D., Massoni, T.: Making Program Refactoring Safer. IEEE Software 27(4), 52–57 (2010)
Schäfer, M., de Moor, O.: Specifying and Implementing Refactorings. In: OOPSLA (2010)
Tip, F., Fuhrer, R.M., Kieżun, A., Ernst, M.D., Balaban, I., Sutter, B.D.: Refactoring Using Type Constraints. TOPLAS 33, 9:1–9:47 (2011)
Schäfer, M., Thies, A., Steimann, F., Tip, F.: A Comprehensive Approach to Naming and Accessibility in Refactoring Java Programs. TSE (2012) (to appear)
Roberts, D., Brant, J., Johnson, R.E.: A Refactoring Tool for Smalltalk. TAPOS 3(4), 253–263 (1997)
Feldthaus, A., Millstein, T., Møller, A., Schäfer, M., Tip, F.: Tool-supported Refactoring for JavaScript. In: OOPSLA (2011)
Li, H., Thompson, S.J., Orösz, G., Tóth, M.: Refactoring with Wrangler, updated: Data and process refactorings, and integration with Eclipse. In: Erlang Workshop, pp. 61–72 (2008)
Li, H., Thompson, S.J.: Clone Detection and Removal for Erlang/OTP within a Refactoring Environment. In: PEPM, pp. 169–178 (2009)
Li, H., Thompson, S.J.: Refactoring Support for Modularity Maintenance in Erlang. In: SCAM, pp. 157–166 (2010)
Li, H., Thompson, S.: A Domain-Specific Language for Scripting Refactorings in Erlang. In: de Lara, J., Zisman, A. (eds.) Fundamental Approaches to Software Engineering. LNCS, vol. 7212, pp. 501–515. Springer, Heidelberg (2012)
Sagonas, K., Avgerinos, T.: Automatic Refactoring of Erlang Programs. In: PPDP, pp. 13–24 (2009)
Overbey, J.L., Negara, S., Johnson, R.E.: Refactoring and the Evolution of Fortran. In: SECSE, pp. 28–34 (2009)
Overbey, J.L., Johnson, R.E.: Regrowing a Language: Refactoring Tools Allow Programming Languages to Evolve. In: OOPSLA (2009)
Overbey, J., Xanthos, S., Johnson, R., Foote, B.: Refactorings for Fortran and High-performance Computing. In: SE-HPCS, pp. 37–39 (2005)
Boniati, B.B., Charão, A.S., Stein, B.D.O., Rissetti, G., Piveta, E.K.: Automated Refactorings for High Performance Fortran Programmes. IJHPSA 3(2/3), 98–109 (2011)
Menon, V., Pingali, K.: A Case for Source-level Transformations in MATLAB. In: DSL, pp. 53–65 (1999)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2013 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Radpour, S., Hendren, L., Schäfer, M. (2013). Refactoring MATLAB. In: Jhala, R., De Bosschere, K. (eds) Compiler Construction. CC 2013. Lecture Notes in Computer Science, vol 7791. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-37051-9_12
Download citation
DOI: https://doi.org/10.1007/978-3-642-37051-9_12
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-37050-2
Online ISBN: 978-3-642-37051-9
eBook Packages: Computer ScienceComputer Science (R0)