Development of Responsive Multi-Device Applications Within Apple Ecosystem
Total Page:16
File Type:pdf, Size:1020Kb
Development of Responsive Multi-Device Applications within Apple Ecosystem Jingkai He Supervisor: Dr Charaka Palansuriya August 14, 2014 Contents Acknowledgement ....................................................................................................... 1 Abbreviations ............................................................................................................... 2 Abstract ........................................................................................................................ 3 1 Introduction and Objectives ................................................................................... 4 2 Background and Literature Review ....................................................................... 6 2.1 State of The Art of Multi-Device Application Development ............................ 6 2.2 Background Knowledge of Apple Ecosystem ................................................... 7 2.2.1 Memory Management ................................................................................. 8 2.2.2 User interface .............................................................................................. 8 2.2.3 Data Model ................................................................................................. 8 2.3 HPC in Multi-Device Application Development .............................................. 8 2.3.1 Clang Compiler ........................................................................................... 9 2.3.2 Grand Central Dispatch ............................................................................ 10 3 Functional Specification and Design ................................................................... 11 3.1 Functional Specification .................................................................................. 11 3.1.1 Basic Functionality ................................................................................... 11 3.1.2 Advanced Functionality ............................................................................ 12 3.2 Architecture ..................................................................................................... 13 3.3 Design .............................................................................................................. 14 3.4 Library Design ................................................................................................. 14 3.5 User Interface Design ...................................................................................... 15 3.5.1 iOS Human Interface Guidelines .............................................................. 15 3.5.2 Mac OS X Human Interface Guidelines ................................................... 16 3.5.3 User Interface for iOS Device .................................................................. 17 3.5.4 User Interface for OS X Device ................................................................ 17 3.5.5 Application Layout ................................................................................... 18 i 3.6 Model Layer Design ........................................................................................ 19 4 Implementation .................................................................................................... 20 4.1 Some Hardware and Software used in the Project ........................................... 20 4.2 Library Implementation ................................................................................... 20 4.2.1 Section and Subsection ............................................................................. 21 4.2.2 Paragraph .................................................................................................. 22 4.2.3 Horizontal Line ......................................................................................... 22 4.2.4 Rich Text among Paragraphs .................................................................... 22 4.2.5 List ............................................................................................................ 24 4.3 Application Implementation ............................................................................ 24 4.3.1 Common Model Layer .............................................................................. 24 4.3.2 iOS Controller Layer Development .......................................................... 25 4.3.3 OS X Controller Layer Development ....................................................... 26 4.4 Design Pattern .................................................................................................. 27 4.4.1 Delegation Pattern .................................................................................... 27 4.4.2 Active Record Pattern ............................................................................... 28 4.4.3 Monkey Patching ...................................................................................... 28 4.4.4 Observer Pattern ....................................................................................... 29 5 Performance Optimisation ................................................................................... 30 5.1 Profiling Approaches ....................................................................................... 30 5.1.1 Hardware for Profiling .............................................................................. 31 6 Result and Evaluation .......................................................................................... 32 6.1 Application Run on OS X device .................................................................... 32 6.2 Application Run on iOS device ....................................................................... 33 6.3 Markdown Parser Optimisation ....................................................................... 35 6.3.1 Object Loading Optimisation ................................................................... 35 6.3.2 Multithreading Optimisation .................................................................... 40 6.3.3 Multithreading Overhead Reducing ......................................................... 44 ii 6.4 Optimisation on OS X Platform ...................................................................... 48 6.4.1 Reduce Unnecessary View Rendering ...................................................... 48 6.4.2 Asynchronous Non-blocking Rendering .................................................. 51 6.5 Optimisation on iOS Platform ......................................................................... 52 6.5.1 Multithreading Optimisation .................................................................... 52 6.5.2 Table View Optimisation .......................................................................... 54 7 Conclusions and Future Work ............................................................................. 56 7.1 Future Work ..................................................................................................... 56 References .................................................................................................................. 58 iii Acknowledgement I would like to express my great appreciation to my supervisor, Dr Charaka Palansuriya, for his generous and thoughtful suggestions and guidance all through the dissertation. I would also like to thank EPCC for providing me with great teaching resource and opportunity to work on the world-class computation hardware during the MSc study. Finally, I would like to thank my parents, for their support and encouragement throughout my study. 1 Abbreviations ARC Automatic Reference Counting GCD Grand Central Dispatch GUI Graphical User Interface SDK Software Development Kit UI User Interface VM Virtual Machine 2 Abstract Mobile devices, such as laptops, tablets and smartphones are increasingly being used in daily work. A successful application is expected to be available on many such devices. The project explores the state-of-the-art in developing multi-device applications with high responsiveness within Apple ecosystem. To identify the methodology suitable for such multi-device development, a notebook application using Markdown syntax is developed on Apple devices. It is implemented to be compatible for devices with different screen size and take the advantage of device-specific hardware. After the notebook application is developed, some high performance related technologies and tools are applied to optimise the performance and improve the responsiveness of the application. The techniques used include enable the application to run on multi-cores by using multithreading, reducing the CPU and memory usage by lazy loading objects and applying caching technology. The responsiveness of the application before and after the performance optimisation is then discussed. 3 1 Introduction and Objectives Presently laptops, smart phones and tablets are one the most popular computing devices used by people. The markers of the operating systems running on those devices usually provide developer with Software Development Kits (to be called SDK for short) so that developers can build applications within the chosen software ecosystem. This can create a win-win situation: As developer can be profitable by making popular software, platform will also be popular due to quantity and quality of the software available on it. A large number of successful applications nowadays are now built for different devices and running on different operating systems. One example is the Microsoft Office, which is built on Windows,