[ACM]
Mobile devices, such as smartphones and tablets, are energy constrained by nature. Therefore, apps targeted for such platforms must be energy-efficient. However, due to the use of energy oblivious design practices often this is not the case. In this paper, we present a light-weight re-factoring technique that can assist in energy-aware app development. Our technique relies on a set of energy-efficiency guidelines that encodes the optimal usage of energy-intensive (hardware) resources in an app. Given a prototype for an app, our technique begins by generating a design-expression for it. A design-expression can be described as a regular-expression representing the ordering of energy-intensive resource usages and invocation of key functionalities (event-handlers) within the app. It also generates a set of defect-expressions, that are design-expressions representing the negation of energy-efficiency guidelines. A nonempty intersection between an app’s design-expression and a defect-expression indicates violation of a guideline (and therefore, potential for re-factoring). To evaluate the efficacy of our re-factoring technique we analysed a suite of open-source Android apps using our technique. The resultant re-factoring when applied, reduced the energy-consumption of these apps between 3 % to 29 %. We also present a case study for one of our subject apps, that captures its design evolution over a period of two-years and more than 200 commits. Our framework found re-factoring opportunities in a number of these commits, that could have been implemented earlier on in the development stages had the developer used an energy-aware refactoring technique such as the one presented in this work.