skip to main content
10.1145/3406085.3409010acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Transformations towards clean functional code

Published:23 August 2020Publication History

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.

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle Scholar
  3. Maurice H. Halstead. 1977. Elements of Software Science (Operating and Programming Systems Series). Elsevier Science Inc., USA.Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle Scholar
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. T. J. McCabe. 1976. A Complexity Measure. IEEE Transactions on Software Engineering SE-2, 4 ( 1976 ), 308-320.Google ScholarGoogle Scholar
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle Scholar
  10. Simon Thompson. 2005. Refactoring Functional Programs. In Advanced Functional Programming, Varmo Vene and Tarmo Uustalu (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 331-357.Google ScholarGoogle Scholar
  11. 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 ScholarGoogle Scholar

Index Terms

  1. Transformations towards clean functional code

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in
      • Published in

        cover image ACM Conferences
        Erlang 2020: Proceedings of the 19th ACM SIGPLAN International Workshop on Erlang
        August 2020
        52 pages
        ISBN:9781450380492
        DOI:10.1145/3406085

        Copyright © 2020 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 23 August 2020

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

        Acceptance Rates

        Overall Acceptance Rate51of68submissions,75%

        Upcoming Conference

        ICFP '24

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader