Patterns and Energy Consumption: Design, Implementation, Studies, and Stories

  • Chapter
  • First Online:
Software Sustainability

Abstract

Software patterns are well known to both researchers and practitioners. They emerge from the need to tackle problems that become ever more common in development activities. Thus, it is not surprising that patterns have also been explored as a means to address issues related to energy consumption. In this chapter, we discuss patterns at code and design level and address energy efficiency not only as the main concern of patterns but also as a side effect of patterns that were not originally intended to deal with this problem. We first elaborate on state-of-the-art energy-oriented and general-purpose patterns. Next, we present cases of how patterns appear naturally as part of decisions made in industrial projects. By looking at the two levels of abstraction, we identify recurrent issues and solutions. In addition, we illustrate how patterns take part in a network of interconnected components and address energetic concerns. The reporting and cases discussed in this chapter emphasize the importance of being aware of energy-efficient strategies to make informed decisions, especially when develo** sustainable software systems.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
EUR 32.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or Ebook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
EUR 29.95
Price includes VAT (Germany)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
EUR 117.69
Price includes VAT (Germany)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
EUR 149.79
Price includes VAT (Germany)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free ship** worldwide - see info
Hardcover Book
EUR 149.79
Price includes VAT (Germany)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free ship** worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    When the practical usage is obvious, we will exclude the illustrative example.

  2. 2.

    Lint is a code analysis tool, provided by the Android SDK, which reports upon finding issues related to the code structural quality.

  3. 3.

    As stated in the Android ArrayMap documentation: http://bit.ly/32hK0y9.

  4. 4.

    AMOLED is a display technology used in mobile devices and stands for Active Matrix Organic Light Emitting Diodes.

  5. 5.

    Fibonacci series is a sequence of numbers in which each number is the sum of the two preceding numbers (i.e., 1, 1, 2, 3, 5, 8, etc.).

  6. 6.

    A real example where the camera was being initiated too early can be found here: https://github.com/signalapp/Signal-Android/commit/cb9f225f5962d399f48b65d5f855e11f146c bbcb (visited on June 15, 2020).

  7. 7.

    Energy Efficiency Guide for iOS Apps—Avoid Extraneous Graphics and Animations available here: https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/AvoidExtraneousGraphicsAndAnimations.html (visited on June 15, 2020).

  8. 8.

    Factory Method, Adapter, Observer, Bridge, and Composite.

  9. 9.

    Abstract Factory, Bridge, Builder, Command, Composite, Decorator, Factory Method, Flyweight, Mediator Observer, Prototype, Proxy, Singleton, Strategy, and Visitor.

  10. 10.

    Number of invocations to methods that are not owned or inherited by the class being measured.

  11. 11.

    Android View documentation: https://developer.android.com/training/custom-views/custom-drawing#createobject

  12. 12.

    IMAP IDLE is a feature defined by the standard RFC 2177 that allows a client to indicate to the server that it is ready to accept real-time notifications.

  13. 13.

    https://developer.mozilla.org/en-US/docs/WebAssembly

  14. 14.

    https://webassembly.org/

  15. 15.

    https://github.com/WebAssembly/design

  16. 16.

    https://webassembly.org/docs/jit-library/

  17. 17.

    https://github.com/WebAssembly/design/pull/719

References

  1. Buschmann F, Meunier R, Rohnert H, Sommerlad P, Stal M (1996) Pattern-oriented software architecture: a system of patterns, vol 1. Wiley

    Google Scholar 

  2. Andrae A, Edler T (2015) On global electricity usage of communication technology: trends to 2030. Challenges 6(1):117–157. https://doi.org/10.3390/challe6010117

    Article  Google Scholar 

  3. Power consumption in data centers is a global problem. https://www.datacenterdynamics.com/en/opinions/power-consumption-data-centers-global-problem/. Accessed 10 Jun 2020

  4. Pinto G, Castor F (2017) Energy efficiency: a new concern for application software developers. Commun ACM 60(12):68–75. https://doi.org/10.1145/3154384

    Article  Google Scholar 

  5. Thorwart A, O’Neill D (2017) Camera and battery features continue to drive consumer satisfaction of smartphones in US. https://www.prnewswire.com/news-releases/camera-and-battery-features-continue-to-drive-consumer-satisfaction-of-smartphones-in-us-300466220.html. Accessed 06 Feb 2019

  6. The most wanted smartphone features. https://www.statista.com/chart/5995/the-most-wanted-smartphone-features. Accessed 24 Jan 2018

  7. Mickle T (2018) Your phone is almost out of battery. Remain calm. Call a doctor. https://www.wsj.com/articles/your-phone-is-almost-out-of-battery-remain-calm-call-a-doctor-1525449283. Accessed 05 Feb 2019

  8. Bragazzi NL, Del Puente G (2014) A proposal for including nomophobia in the new dsm-v. Psychol Res Behav Manag 7:155. https://doi.org/10.2147/PRBM.S41386

    Article  Google Scholar 

  9. Fu B, Lin J, Li L, Faloutsos C, Hong J, Sadeh N (2013) Why people hate your app: making sense of user feedback in a mobile app store. In: Proc. ACM SIGKDD 19th Int. Conf. Knowledge Discovery and Data Mining (KDD ’13). ACM, Chicago, IL, pp 1276–1284. https://doi.org/10.1145/2487575.2488202

  10. Khalid H, Shihab E, Nagappan M, Hassan AE (2015) What do mobile app users complain about? IEEE Softw 32(3):70–77. https://doi.org/10.1109/MS.2014.50

    Article  Google Scholar 

  11. Manotas I, Bird C, Zhang R, Shepherd D, Jaspan C, Sadowski C, Pollock L, Clause J (2016) An empirical study of practitioners’ perspectives on green software engineering. In: Proc. IEEE/ACM 38th Int. Conf. Software Engineering (ICSE ’16), pp. 237–248. IEEE, Austin, TX. https://doi.org/10.1145/2884781.2884810

  12. Pang C, Hindle A, Adams B, Hassan AE (2016) What do programmers know about software energy consumption? IEEE Softw 33(3):83–89. https://doi.org/10.1109/MS.2015.83

    Article  Google Scholar 

  13. Pinto G, Castor F, Liu YD (2014) Mining questions about software energy consumption. In: Proc. 11th Working Conf. Mining Software Repositories (MSR ’14). ACM, Hyderabad, pp 22–31. https://doi.org/10.1145/2597073.2597110

  14. Couto M, Saraiva J, Fernandes JP (2020) Energy refactorings for android in the large and in the wild. In: Proc. IEEE 27th Int. Conf. Software Analysis, Evolution and Reengineering (SANER ’20). London, ON, pp 217–228. https://doi.org/10.1109/SANER48275.2020.9054858

  15. Cruz L, Abreu R (2017) Performance-based guidelines for energy efficient mobile applications. In: Proc. IEEE/ACM 4th Int. Conf. Mobile Software Engineering and Systems (MobileSoft ’17). IEEE, Buenos Aires, pp 46–57. https://doi.org/10.1109/MOBILESoft.2017.19

  16. Cruz L, Abreu R (2018) Using automatic refactoring to improve energy efficiency of android apps. In: Proc. XXI Ibero-American Conf. Software Engineering (CIbSE ’18). Bogota, Colombia, pp 1–14

    Google Scholar 

  17. Palomba F, Di Nucci D, Panichella A, Zaidman A, De Lucia A (2019) On the impact of code smells on the energy consumption of mobile applications. Inf Softw Technol 105:43–55. https://doi.org/10.1016/j.infsof.2018.08.004

    Article  Google Scholar 

  18. Vekris P, Jhala R, Lerner S, Agarwal Y (2012) Towards verifying Android apps for the absence of no-sleep energy bugs. In: Proc. USENIX 5th Conf. Power-Aware Computing and Systems (HotPower ’12). USENIX Association, Hollywood, CA

    Google Scholar 

  19. Linares-Vásquez M, Bavota G, Bernal-Cárdenas C, Oliveto R, Di Penta M, Poshyvanyk D (2014) Mining energy-greedy API usage patterns in android apps: an empirical study. In: Proc. 11th Working Conf. Mining Software Repositories (MSR ’14). ACM, Hyderabad, pp 2–11. https://doi.org/10.1145/2597073.2597085

  20. Carette A, Younes MAA, Hecht G, Moha N, Rouvoy R (2017) Investigating the energy impact of Android smells. In: Proc. IEEE 24th Int. Conf. Software Analysis, Evolution and Reengineering (SANER ’17). Klagenfurt, Austria, pp 115–126. https://doi.org/10.1109/SANER.2017.7884614

  21. Morales R, Saborido R, Khomh F, Chicano F, Antoniol G (2018) EARMO: an energy-aware refactoring approach for mobile apps. IEEE Trans Softw Eng 44(12):1176–1206. https://doi.org/10.1109/TSE.2017.2757486

    Article  Google Scholar 

  22. Saborido R, Morales R, Khomh F, Guéhéneuc YG, Antoniol G (2018) Getting the most from map data structures in Android. Empir Softw Eng 23(5):2829–2864. https://doi.org/10.1007/s10664-018-9607-8

    Article  Google Scholar 

  23. Li D, Halfond WG (2014) An investigation into energy-saving programming practices for android smartphone app development. In: Proc. 3rd Int. Workshop on Green and Sustainable Software (GREENS ’14). ACM, Hyderabad, pp 46–53. https://doi.org/10.1145/2593743.2593750

  24. Cruz L, Abreu R (2019) Catalog of energy patterns for mobile applications. Empir Softw Eng 24(4):2209–2235. https://doi.org/10.1007/s10664-019-09682-0

    Article  Google Scholar 

  25. Agolli T, Pollock L, Clause J (2017) Investigating decreasing energy usage in mobile apps via indistinguishable color changes. In: Proc. IEEE/ACM 4th Int. Conf. Mobile Software Engineering and Systems (MOBILESoft ’17). IEEE, Buenos Aires, pp 30–34. https://doi.org/10.1109/MOBILESoft.2017.17

  26. Li D, Tran AH, Halfond WG (2014) Making web applications more energy efficient for old smartphones. In: Proc. 36th Int. Conf. Software Engineering (ICSE ’14). ACM, Hyderabad, pp 527–538. https://doi.org/10.1145/2568225.2568321

  27. Li D, Tran AH, Halfond WG (2015) Nyx: a display energy optimizer for mobile web apps. In: Proc. 10th Joint Meeting on Foundations of Software Engineering (ESEC/FSE ’15). ACM, Bergamo, Italy, pp 958–961. https://doi.org/10.1145/2786805.2803190

  28. Linares-Vásquez M, Bernal-Cárdenas C, Bavota G, Oliveto R, Di Penta M, Poshyvanyk D (2017) Gemma: multi-objective optimization of energy consumption of guis in android apps. In: Proc. 39th Int. Conf. Software Engineering Companion (ICSE-C ’17). IEEE, Buenos Aires, pp 11–14. https://doi.org/10.1109/ICSE-C.2017.10

  29. Banerjee A, Roychoudhury A (2016) Automated re-factoring of android apps to enhance energy-efficiency. In: Proc. IEEE/ACM 3rd Int. Conf. Mobile Software Engineering and Systems (MOBILESoft ’16). ACM, Austin, TX, pp 139–150

    Chapter  Google Scholar 

  30. Liu Y, Xu C, Cheung SC, Terragni V (2016) Understanding and detecting wake lock misuses for android applications. In: Proc. ACM SIGSOFT 24th Int. Symposium on Foundations of Software Engineering (FSE ’16). ACM, Seattle, WA, pp 396–409. https://doi.org/10.1145/2950290.2950297

  31. Pathak A, **dal A, Hu YC, Midkiff SP (2012) What is kee** my phone awake?: Characterizing and detecting no-sleep energy bugs in smartphone apps. In: Proc. 10th Int. Conf. Mobile Systems, Applications, and Services (MobiSys ’12). ACM, Windermere, pp 267–280. https://doi.org/10.1145/2307636.2307661

  32. Metri G, Agrawal A, Peri R, Shi W (2012) What is eating up battery life on my smartphone: a case study. In: Proc. 2nd Int. Conf. Energy Aware Computing (ICEAC ’12). IEEE, Morphou, Cyprus, pp 1–6. https://doi.org/10.1109/ICEAC.2012.6471003

  33. Chowdhury S, Di Nardo S, Hindle A, Jiang ZMJ (2018) An exploratory study on assessing the energy impact of logging on android applications. Empir Softw Eng 23(3):1422–1456. https://doi.org/10.1007/s10664-017-9545-x

    Article  Google Scholar 

  34. Corral L, Georgiev AB, Janes A, Kofler S (2015) Energy-aware performance evaluation of android custom kernels. In: Proc. IEEE/ACM 4th Int. Workshop on Green and Sustainable Software (GREENS ’15). IEEE, Florence, pp 1–7. https://doi.org/10.5555/2820158.2820160

  35. Huang G, Cai H, Swiech M, Zhang Y, Liu X, Dinda P (2017) DelayDroid: an instrumented approach to reducing tail-time energy of Android apps. SCIENCE CHINA Inf Sci 60(1):012106. https://doi.org/10.1007/s11432-015-1026-y

    Article  Google Scholar 

  36. Gottschalk M, Jelschen J, Winter A (2014) Saving energy on mobile devices by refactoring. In: Proc. 28th Conf. Environmental Informatics (EnviroInfo ’14). BIS-Verlag, Oldenburg, Germany, pp 437–444

    Google Scholar 

  37. Kim D, Jung N, Chon Y, Cha H (2016) Content-centric energy management of mobile displays. IEEE Trans Mob Comput 15(8):1925–1938. https://doi.org/10.1109/TMC.2015.2467393

    Article  Google Scholar 

  38. Gamma E, Helm R, Johnson R, Vlissides JM (1994) Design patterns: elements of reusable object-oriented software, 1st edn. Addison-Wesley Professional

    MATH  Google Scholar 

  39. Ampatzoglou A, Charalampidou S, Stamelos I (2013) Research state of the art on GoF design patterns: a map** study. J Syst Softw 86(7):1945–1964. https://doi.org/10.1016/j.jss.2013.03.063

    Article  Google Scholar 

  40. Hsueh NL, Chu PH, Chu W (2008) A quantitative approach for evaluating the quality of design patterns. J Syst Softw 81(8):1430–1439. https://doi.org/10.1016/j.jss.2007.11.724

    Article  Google Scholar 

  41. Huston B (2001) The effects of design pattern application on metric scores. J Syst Softw 58(3):261–269. https://doi.org/10.1016/s0164-1212(01)00043-7

    Article  Google Scholar 

  42. Ampatzoglou A, Chatzigeorgiou A, Charalampidou S, Avgeriou P (2015) The effect of GoF design patterns on stability: a case study. IEEE Trans Softw Eng 41(8):781–802. https://doi.org/10.1109/tse.2015.2414917

    Article  Google Scholar 

  43. Feitosa D, Ampatzoglou A, Avgeriou P, Chatzigeorgiou A, Nakagawa E (2019) What can violations of good practices tell about the relationship between GoF patterns and run-time quality attributes? Inf Softw Technol 105:1–16. https://doi.org/10.1016/j.infsof.2018.07.014

    Article  Google Scholar 

  44. Khomh F, Gueheneuc YG, Antoniol G (2009) Playing roles in design patterns: An empirical descriptive and analytic study. In: Proc. IEEE 25th Int. Conf. Software Maintenance (ICSM ’09). IEEE, Timişoara, Romania. https://doi.org/10.1109/icsm.2009.5306327

  45. Adamczyk P (2004) Selected patterns for implementing finite state machines. In: Proc. 11th Conf. Pattern Languages of Programs (PLoP ’04). Monticello, IL, pp 1–41

    Google Scholar 

  46. Ampatzoglou A, Charalampidou S, Stamelos I (2013) Design pattern alternatives. In: Proc. 17th Panhellenic Conf. Informatics (PCI ’13). ACM, Thessaloniki. https://doi.org/10.1145/2491845.2491857

  47. Fowler M, Beck K, Brant J, Opdyke W, Roberts D (1999) Refactoring: improving the design of existing code. Object technology series. Addison-Wesley

    Google Scholar 

  48. Lyardet FD (1997) The dynamic template pattern. In: Proc. 4th Conf. Pattern Languages of Programs (PLoP ’97). Monticello, IL, pp 1–8. https://hillside.net/plop/plop/plop97/Proceedings/chai.pdf

  49. Saúde AV, Victório RASS, Coutinho GCA (2010) Persistent state pattern. In: Proc. 17th Conf. Pattern Languages of Programs (PLoP ’10). ACM, Reno, NV. https://doi.org/10.1145/2493288.2493293

  50. Litke A, Zotos K, Chatzigeorgiou A, Stephanides G (2005) Energy consumption analysis of design patterns. Proc World Acad Sci Eng Technol 6:86–90

    Google Scholar 

  51. Sahin C, Cayci F, Gutiérrez ILM, Clause J, Kiamilev F, Pollock L, Winbladh K (2012) Initial explorations on design pattern energy usage. In: Proc. 1st Int. Workshop on Green and Sustainable Software (GREENS ’12). IEEE, Zurich, pp 55–61. https://doi.org/10.1109/GREENS.2012.6224257

  52. Noureddine A, Rajan A (2015) Optimising energy consumption of design patterns. In: Proc. 37th Int. Conf. Software Engineering (ICSE ’15). IEEE, pp 623–626

    Google Scholar 

  53. Feitosa D, Alders R, Ampatzoglou A, Avgeriou P, Nakagawa EY (2017) Investigating the effect of design patterns on energy consumption. J Softw Evol Process 29(2):e1851. https://doi.org/10.1002/smr.1851

    Article  Google Scholar 

  54. Harrison NB, Avgeriou P, Zdun U (2007) Using patterns to capture architectural decisions. IEEE Softw 24(4):38–45. https://doi.org/10.1109/MS.2007.124

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Daniel Feitosa .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Feitosa, D., Cruz, L., Abreu, R., Fernandes, J.P., Couto, M., Saraiva, J. (2021). Patterns and Energy Consumption: Design, Implementation, Studies, and Stories. In: Calero, C., Moraga, M.Á., Piattini, M. (eds) Software Sustainability. Springer, Cham. https://doi.org/10.1007/978-3-030-69970-3_5

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-69970-3_5

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-69969-7

  • Online ISBN: 978-3-030-69970-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics

Navigation