• Medientyp: E-Artikel
  • Titel: Energy efficiency of the Visitor Pattern: contrasting Java and C++ implementations
  • Beteiligte: Connolly Bree, Déaglán; Ó Cinnéide, Mel
  • Erschienen: Springer Science and Business Media LLC, 2023
  • Erschienen in: Empirical Software Engineering
  • Sprache: Englisch
  • DOI: 10.1007/s10664-023-10387-8
  • ISSN: 1382-3256; 1573-7616
  • Schlagwörter: Software
  • Entstehung:
  • Anmerkungen:
  • Beschreibung: <jats:title>Abstract</jats:title><jats:p>Design patterns are applied frequently during software evolution in order to make the software more flexible and amenable to extension. One little-studied aspect of design patterns is their propensity to increase run-time energy consumption due to the indirection and additional structure they introduce. In this paper we study the impact of the Visitor pattern on energy efficiency. The Visitor pattern separates an algorithm from the objects it acts upon and improves maintainability by placing each algorithm within a single visitor class. This is at the cost of increased indirection due to the double dispatch required when the algorithm is invoked. We experimentally investigate the energy impact of varying the implementation of this pattern, and of removing the pattern entirely from software written in Java and C++. In our results we observe energy consumption reductions greater than 7% in a Java-based textbook example when the pattern is implemented using reflective dispatch, and reductions of over 10% when experimenting with an open source Java project, JavaParser. The complete removal of the pattern yields more complex results, with little impact in the textbook example but reductions of over 7% in the JavaParser study. To explore the generalisability of our findings, we subsequently apply the same transformations to the C++ based CppParser. Total pattern removal here sees energy consumption reductions of over 66% while the reflective dispatch approach increases energy consumption by up to 2012%. Our results highlight the energy savings that can be achieved when the Visitor pattern is removed both in Java and C++ implementations, and also show that some language specific features can allow for further energy savings when the implementation of the pattern is varied.</jats:p>