
Masaryk University Faculty of Informatics An optimization of a long-term mobile application IT project with an emphasis on sustainability Bachelor’s Thesis Marek Abaffy Brno, Fall 2016 Masaryk University Faculty of Informatics An optimization of a long-term mobile application IT project with an emphasis on sustainability Bachelor’s Thesis Marek Abaffy Brno, Fall 2016 This is where a copy of the official signed thesis assignment and a copy ofthe Statement of an Author is located in the printed version of the document. Declaration Hereby I declare that this paper is my original authorial work, which I have worked out on my own. All sources, references, and literature used or excerpted during elaboration of this work are properly cited and listed in complete reference to the due source. Marek Abaffy Advisor: RNDr. Jaroslav Škrabálek i Acknowledgement First, I would like to express gratitude to my supervisor, RNDr. Jaroslav Škrabálek, for allowing me to work on this thesis under his supervision. I am grateful for his helpful suggestions and valuable comments. I would also like to extend my thanks to family, colleagues, and friends. It is due to their continuous great encouragement that I have been able to complete this work and finish my studies. ii Abstract This implementation thesis describes a process of optimizing existing Android application project. It focuses on improving an application’s internal code structure using the latest Android development technolo- gies. As a part of this thesis, the application is migrated from outdated push notification provider Parse to the new Firebase Cloud Messag- ing service. The optimized application is then tested and compared with the original version. The result of this thesis is an application installation file, that is ready to be uploaded to the Google Play store. iii Keywords Android, application, refactoring, optimization, maintenance, code analysis, REST API, performance ... iv Contents 1 Introduction 1 1.1 Mobile application maintenance ...............2 2 Technologies overview 4 2.1 Data Binding .........................4 2.2 RecyclerView .........................4 2.3 ConstraintLayout .......................5 2.4 Android Annotations .....................6 2.4.1 TypeDef annotations . .6 2.5 ActiveAndroid ........................7 2.6 EventBus ...........................7 3 About the application 8 4 Code analysis 10 4.1 Application architecture ................... 10 4.2 Package structure ....................... 10 4.3 Third-party dependencies ................... 11 4.4 Code style ........................... 12 4.5 Layout complexity ...................... 13 4.6 Hard-coded strings ...................... 13 4.7 Performance issues ...................... 13 5 API optimization design 15 5.1 Optimizing data-update flow ................. 15 6 Refactoring process 18 6.1 Package structure ....................... 18 6.1.1 Product flavors . 18 6.2 Designing code practices ................... 19 6.2.1 Naming conventions . 19 6.2.2 Starting activities and fragments . 19 6.3 Extracting hard-coded strings ................ 20 6.4 Creating application styles .................. 20 6.5 Layout optimization ...................... 21 6.6 Binding data to layouts .................... 21 v 6.7 Replacing enums with static constants ............ 24 6.8 Optimizing list implementations ............... 24 6.9 Networking optimization ................... 25 6.9.1 Unifying networking libraries . 25 6.9.2 Creating generic requests . 25 6.9.3 Implementing API changes . 25 6.10 Storing structured data in database .............. 26 6.11 Dispatching events ...................... 26 6.12 Removing unnecessary dependencies ............. 27 7 Push notifications 28 7.1 Firebase Cloud Messaging .................. 28 7.2 Implementation ........................ 29 8 Testing 31 8.1 Functional testing ....................... 31 8.1.1 Distribution . 31 8.1.2 Execution . 31 8.2 Performance testing ...................... 34 8.2.1 Activity start time . 34 8.2.2 Memory usage . 37 9 Conclusion 39 9.1 Future improvements ..................... 39 Bibliography 40 Index 42 A Naming conventions 42 B Constraint layout editor 43 C Code samples 44 vi List of Tables 4.1 Application’s third-party dependencies. 12 4.2 Performance issues with their priority. 14 5.1 The designed API endpoints. 15 6.1 Deleted third-party dependencies. 27 A.1 String constants naming. 42 A.2 File assets naming. 42 A.3 Layout files naming. 42 vii List of Figures 2.1 RecyclerView structure [7]. 5 2.2 EventBus communication. 7 3.1 Number of installations on active devices by Android platform. 9 5.1 API update pattern [15]. 16 8.1 Example of reported issues. 32 8.2 Bug tracking during development. 33 8.3 Activity start time [ms] on Nexus 5X. 35 8.4 Activity start time [ms] on Cubot GT99. 36 8.5 General memory usage (original) on Nexus 9. 37 8.6 General memory usage (optimized) on Nexus 9. 37 8.7 Scrolling memory usage (original) on Nexus 9. 38 8.8 Scrolling memory usage (optimized) on Nexus 9. 38 B.1 Using ConstraintLayout to design menu buttons. 43 viii 1 Introduction In recent years, the market with mobile applications has maintained an immense upward trajectory. As of today, the Google Play store features over 2,4 million1 apps for Android. With this in mind, it is obvious that to create a successful application it takes more than just to develop it. The market growth, new technologies, and rising users demands require developers to be flexible and always search for ways to improve their applications. Maintenance is needed to ensure that the application continues to satisfy user requirements. The maintenance part often accounts for 67% of the application life-cycle cost [1]. To achieve a state, where each optimization or feature implementation can be integrated easily and often by a different developer, it is important to have a maintain- able and clean source code. According to Pogoski, 40% to 60% of the maintenance effort is devoted to understanding the software to be modified. Trying to find a defect in a 500K line of code systemthat the maintainer did not develop is a challenge for him [2]. This thesis focuses on analyzing a source code of an already ex- isting mobile application, describing its weaknesses and proposing possible improvements. The theoretical part contains information about the latest Android development features designed to improve stability and performance of mobile applications. The implementa- tion part focuses on optimization of the application. The main goal is to refactor problematic parts, enhance performance, remove existing bugs and while doing so, set it up for future development. As a part of this bachelor thesis, the mobile application is fully migrated from outdated push notification service Parse to the new app platform Fire- base. The optimized version of the application is then tested and its performance analyzed. The result of this thesis is an apk2 file, ready to be uploaded to the Google Play store. 1. https://www.statista.com/statistics/266210/number-of-available- applications-in-the-google-play-store/ 2. File format used by the Android for distribution and installation of applications. 1 1. Introduction 1.1 Mobile application maintenance The software maintenance phase covers the whole procedure ranging from the delivery of the software to its retirement [3]. The IEEE 1998 Standard for Software Maintenance defines it as following [4]: Modification of a software product after delivery to cor- rect faults, to improve performance or other attributes, or to adapt the product to a modified environment. Software maintenance encompasses four different types [3, 5]: • Corrective maintenance — Corrective maintenance refers to the fixing actions performed when software failures occur, that is, the bugs or relevant problems that resulting in critical failures of software products. • Perfective maintenance — Perfective maintenance aims for the perfection of software products concerning some issues influ- encing the usability of users which most users would prefer getting them improved but could endure being without them. • Adaptive maintenance — Adaptive maintenance deals with the issues concerning the upgrade of system or hardware envi- ronment. • Preventive maintenance — Preventive maintenance is certain modification on the source code in order to prevent a software system from future crash, which aims for enhancement of the maintainability and credibility. Each of those types represents a different, but equally important part of an application maintenance process. For instance, many mod- ern mobile applications collect data about bugs in a form of crashes using crash reporting tools. These bugs can be analyzed and fixed in corrective maintenance. Perfective maintenance is especially important since it focuses on users and their feedback. Developers and compa- nies usually pay a lot of attention to user reviews, as they are one of the most important resources of feedbacks. Adaptive maintenance normally occurs when there is a major update in a mobile system [3]. 2 1. Introduction In the Android world, this means that with every release of a new SDK3 developers should verify that the application behaves correctly and users are not experiencing any issues. Also, adaptive maintenance closely relates to using third-party dependencies. If, for some reason, a dependency that an application uses changes its functionality or shuts down completely, maintenance is required. This thesis primar- ily focuses on the preventive maintenance.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages57 Page
-
File Size-