ABSTRACT
The programming style has an impact on the readability and comprehensibility of the source code, and it may also affect run-time performance. This statement also holds for functional languages when the functional style is mixed with imperative design. In this paper, we present a couple of methods that can refactor imperatively styled Erlang source-code into a more functionally styled one. This can be done by transforming unnecessary calls to length, hd and tl into pattern matching or by lifting particular nested expressions. The results of our investigations indicate that these refactorings can not only shorten the length of the source code but also affect the complexity/readability. In this paper, we present some refactorings; moreover, real-life examples and data for its validation.
- Thanassis Avgerinos and Konstantinos Sagonas. 2009. Cleaning up Erlang Code is a Dirty Job but Somebody's Gotta Do It. In Proceedings of the 8th ACM SIGPLAN Workshop on ERLANG (Edinburgh, Scotland) ( ERLANG '09). Association for Computing Machinery, New York, NY, USA, 1-10. htps://doi.org/10.1145/1596600.1596602Google ScholarDigital Library
- I. Bozó, D. Horpácsi, Z. Horváth, R. Kitlei, J. Köszegi, Tejfel. M., and M Tóth. 2011. RefactorErl-Source Code Analysis and Refactoring in Erlang. In Proceedings of the 12th Symposium on Programming Languages and Software Tools, ISBN 978-9949-23-178-2. Tallin, Estonia, 138-148.Google Scholar
- Maurice H. Halstead. 1977. Elements of Software Science (Operating and Programming Systems Series). Elsevier Science Inc., USA.Google ScholarDigital Library
- Dániel Horpácsi, Judit Koszegi, and Simon Thompson. 2016. Towards Trustworthy Refactoring in Erlang. Electronic Proceedings in Theoretical Computer Science 216 ( 07 2016 ), 83-103. htps://doi.org/10.4204/EPTCS. 216.5Google Scholar
- Huiqing Li, Simon Thompson, György Orosz, and Melinda Tóth. 2008. Refactoring with Wrangler, Updated: Data and Process Refactorings, and Integration with Eclipse. In Proceedings of the 7th ACM SIGPLAN Workshop on ERLANG (Victoria, BC, Canada) ( ERLANG '08). Association for Computing Machinery, New York, NY, USA, 61-72. htps://doi.org/10.1145/1411273.1411283Google ScholarDigital Library
- T. J. McCabe. 1976. A Complexity Measure. IEEE Transactions on Software Engineering SE-2, 4 ( 1976 ), 308-320.Google Scholar
- Sanjay Misra and Ibrahim Akman. 2008. A Unique Complexity Metric. In Computational Science and Its Applications-ICCSA 2008, Osvaldo Gervasi, Beniamino Murgante, Antonio Laganà, David Taniar, Youngsong Mun, and Marina L. Gavrilova (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 641-651.Google ScholarDigital Library
- Konstantinos Sagonas and Thanassis Avgerinos. 2009. Automatic Refactoring of Erlang Programs. In Proceedings of the 11th ACM SIGPLAN Conference on Principles and Practice of Declarative Programming (Coimbra, Portugal) (PPDP '09). Association for Computing Machinery, New York, NY, USA, 13-24. htps://doi.org/10.1145/1599410.1599414Google ScholarDigital Library
- Jingqiu Shao and Yingxu Wang. 2003. A new measure of software complexity based on cognitive weights. Canadian Journal of Electrical and Computer Engineering 28, 2 ( 2003 ), 69-74.Google Scholar
- Simon Thompson. 2005. Refactoring Functional Programs. In Advanced Functional Programming, Varmo Vene and Tarmo Uustalu (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 331-357.Google Scholar
- M. Tóth and I. Bozó. 2012. Static Analysis of Complex Software Systems Implemented in Erlang. Central European Functional Programming Summer School-Fourth Summer School, CEFP 2011, Revisited Selected Lectures, Lecture Notes in Computer Science (LNCS), Vol. 7241, pp. 451-514, Springer-Verlag, ISSN: 0302-9743.Google Scholar
Index Terms
- Transformations towards clean functional code
Recommendations
Tool support for refactoring functional programs
WRT '08: Proceedings of the 2nd Workshop on Refactoring ToolsWe present the Haskell Refactorer, HaRe, and the Erlang Refactorer, Wrangler, as examples of fully-functional refactoring tools for functional programming languages. HaRe and Wrangler are designed to handle multi-module projects in complete languages: ...
Tool support for refactoring functional programs
PEPM '08: Proceedings of the 2008 ACM SIGPLAN symposium on Partial evaluation and semantics-based program manipulationWe demonstrate the Haskell Refactorer, HaRe, and the Erlang Refactorer, Wrangler, as examples of fully-functional refactoring tools for functional programming languages. HaRe and Wrangler are designed to handle multi-module projects in complete ...
Quickchecking refactoring tools
Erlang '10: Proceedings of the 9th ACM SIGPLAN workshop on ErlangRefactoring is the transformation of program source code in a way that preserves the behaviour of the program. Many tools exist for automating a number of refactoring steps, but these tools are often poorly tested. We present an automated testing ...
Comments