Comparing Modifiability of React Native and Two Native Codebases
Total Page:16
File Type:pdf, Size:1020Kb
Linköping University | Department of Computer Science Master thesis, 30 ECTS | Datateknik 2017 | LIU-IDA/LITH-EX-A--17/025--SE Comparing modifiability of React Native and two native codebases Robin Abrahamsson David Berntsen Supervisor : Lena Buffoni Examiner : Ola Leifler Linköpings universitet SE–581 83 Linköping +46 13 28 10 00 , www.liu.se Upphovsrätt Detta dokument hålls tillgängligt på Internet – eller dess framtida ersättare – under 25 år från publiceringsdatum under förutsättning att inga extraordinära omständigheter uppstår. Tillgång till dokumentet innebär tillstånd för var och en att läsa, ladda ner, skriva ut enstaka kopior för enskilt bruk och att använda det oförändrat för ickekommersiell forskning och för undervisning. Överföring av upphovsrätten vid en senare tidpunkt kan inte upphäva detta tillstånd. All annan användning av dokumentet kräver upphovsmannens medgivande. För att garantera äktheten, säkerheten och tillgängligheten finns lösningar av teknisk och admin- istrativ art. Upphovsmannens ideella rätt innefattar rätt att bli nämnd som upphovsman i den omfattning som god sed kräver vid användning av dokumentet på ovan beskrivna sätt samt skydd mot att dokumentet ändras eller presenteras i sådan form eller i sådant sam- manhang som är kränkande för upphovsmannenslitterära eller konstnärliga anseende eller egenart. För ytterligare information om Linköping University Electronic Press se förlagets hemsida http://www.ep.liu.se/. Copyright The publishers will keep this document online on the Internet – or its possible replacement – for a period of 25 years starting from the date of publication barring exceptional circum- stances. The online availability of the document implies permanent permission for anyone to read, to download, or to print out single copies for his/hers own use and to use it unchanged for non-commercial research and educational purpose. Subsequent transfers of copyright cannot revoke this permission. All other uses of the document are conditional upon the con- sent of the copyright owner. The publisher has taken technical and administrative measures to assure authenticity, security and accessibility. According to intellectual property law the author has the right to be mentioned when his/her work is accessed as described above and to be protected against infringement. For additional information about the Linköping Uni- versity Electronic Press and its procedures for publication and for assurance of document integrity, please refer to its www home page: http://www.ep.liu.se/. c Robin Abrahamsson David Berntsen Abstract Creating native mobile application on multiple platforms generate a lot of duplicate code. This thesis has evaluated if the code quality attribute modifiability improves when migrating to React Native. One Android and one iOS codebase existed for an application and a third codebase was developed with React Native. The measurements of the code- bases were based on the SQMMA-model. The metrics for the model were collected with static analyzers created specifically for this project. The results created consists of graphs that show the modifiability for some specific components over time and graphs that show the stability of the platforms. These graphs show that when measuring code metrics on applications over time it is better to do this on a large codebase that has been developed for some time. When calculating a modifiability value the sum of the metrics and the average value of the metrics between files should be used and it is shown that the React Native platform seems to be more stable than native. Acknowledgments We would like to thank our supervisor Lena Buffoni and examiner Ola Leifler, both from Linköping University, for all the feedback and help throughout our entire thesis. Helping us to stay on the right path and get the best result possible. Thanks to our opponents Ludvig Helén and Petra Öhlin for reviewing our thesis multiple times and giving valuable feed- back to improve the thesis. We would like to thank Valtech AB for providing applications, supervision and a place to do our work. v Contents Abstract iii Acknowledgments iv Contents vi List of Figures viii List of Tables ix 1 Introduction 1 1.1 Motivation . 1 1.2 Aim............................................ 2 1.3 Research Questions . 2 1.4 Delimitations . 2 2 Theory 3 2.1 Mobile Applications . 3 2.2 Cross-platform Tools . 4 2.3 Cost of Software Development . 7 2.4 Code Metrics . 7 2.5 International Standards . 11 2.6 Maintainability . 11 2.7 Modifiability . 13 2.8 Quality Models . 13 2.9 Static Analysis . 16 2.10 Case Study . 16 2.11 Related Work . 16 3 Method 19 3.1 Description of Research Method . 19 3.2 Components and Files . 24 4 Results 29 4.1 Releases . 29 4.2 Modifiability . 33 5 Discussion 41 5.1 Method . 41 5.2 Results . 43 5.3 The Work in a Wider Context . 45 6 Conclusion 47 6.1 Future Work . 47 vi Bibliography 49 List of Figures 3.1 The start page of the application, showing navbar and list view. 25 3.2 Navbar example with hamburger menu, title and search button. 26 3.3 Menu example of menu sliding in from the left, with menu items and a separator. 27 3.4 Example of a horizontal list view that has to be scrolled to show all content. 28 4.1 iOS release data . 30 4.2 Android release data . 31 4.3 React Native release data . 33 4.4 Navbar component data from native and React Native applications over time . 35 4.5 Menu component data from native and React Native applications over time . 36 4.6 List view component data from native and React Native applications over time . 38 4.7 Migrated application data from native and React Native applications over time . 40 viii List of Tables 1.1 Worldwide market share by operating system in 2014 . 1 1.2 United States market share by operating system in 2015 . 1 2.1 SQMMA - Computation formulas . 14 2.2 QMOOD - Computation formulas . 15 3.1 Metrics extracted from the static analyzers . 22 3.2 Metrics, tools and source . 22 3.3 Metrics calculations . 22 4.1 iOS API changes over time and releases . 29 4.2 Average iOS API changes per version . 29 4.3 Android API changes over time and releases . 31 4.4 React Native API changes over time and releases . 32 4.5 The maximum and minimum modifiability values for the Navbar component. 34 4.6 The maximum and minimum modifiability values for the Menu component. 36 4.7 The maximum and minimum modifiability values for the List view component. 37 4.8 The maximum and minimum modifiability values for the all components. 39 ix 1 Introduction There are over 2 billion smartphones in the world with different operating systems on them [57]. Android had a significant market share of all the platforms that were sold to end users worldwide in 2014, as can seen in Table 1.1. Even though Android had a vast vast majority of the market share in the world, in the United States Android doesn’t have the same kind of dominance. In 2015 Android only had 52.4% of the market share in the United States, as can be seen in Table 1.2. So if a company wants to be available and competetive on the entire market and have applications on all platforms they must either create a native application for each platform, create hybrid applications for the same platforms or a web application that is usable by every platform. Depending on which route one decides to go, it comes with some pros and cons. Operating system 2014 Units 2014 Market Share (%) Android 1,004,675 80.7 iOS 191,426 15.4 Windows 35,133 2.8 BlackBerry 7,911 0.6 Other OS 5,745 0.5 Table 1.1: Worldwide market share by operating system in 2014 [27] Operating system Mar-15 Market Share (%) Jun-15 Market Share (%) Android 52.4 51.6 iOS 42.6 44.1 Windows 3.3 2.9 BlackBerry 1.6 1.2 Symbian 0.1 0.1 Table 1.2: United States market share by operating system in 2015 [15] 1.1 Motivation Creating native mobile applications on multiple platforms generates a lot of duplicate code, especially for the basic functionality and business logic. Due to differences in syntax, lan- guage, test suites and packages in the different platforms, reusability and sharing of code is not really possible. This increases the amount of hours needed to release, maintain and test applications for multiple platforms which leads to a higher development and maintenance cost. React Native1 is a project started by Facebook which addresses the problem in an in- teresting way. It gives the possibility have one codebase for multiple applications with the possibility to still use platform specific components. 1https://github.com/facebook/react-native 1 1.2. Aim The work for this thesis has been done at the company Valtech which is an IT-consultant firm located in Stockholm. For many customers Valtech creates web services and often com- panies also want to have mobile applications for both Android and iOS. To have only one codebase instead of two would require less work and people. If it would be possible to have only one codebase for both applications it would be important to know if it gives any ad- vantages to switch from the native codebases to a cross-platform codebase and how much investment would be necessary. 1.2 Aim This thesis is exploratory, which means that it investigates a new area. The aim is to evaluate if certain quality attribute can be improved when migrating code from native codebases to a cross platform tool like React Native. Specifically the modifiability quality attribute, presented in the ISO/IEC 25010 standard [36] is looked at.