Table Of ContentDESIGNING PLATFORM
INDEPENDENT MOBILE
APPS AND SERVICES
IEEEPressEditorialBoard
TariqSamad,EditorinChief
GeorgeW.Arnold XiaoouLi RayPerez
GiancarloFortino VladimirLumelsky LindaShafer
DmitryGoldgof Pui-InMak ZidongWang
EkramHossain JeffreyNanzer MengChuZhou
KennethMoore,DirectorofIEEEBookandInformationServices(BIS)
AboutIEEEComputerSociety
IEEE Computer Society is the world’s leading computing membership organi-
zation and the trusted information and career-development source for a global
workforce of technology leaders including: professors, researchers, software
engineers,ITprofessionals,employers,andstudents.Theunmatchedsourcefor
technologyinformation,inspiration,andcollaboration,theIEEEComputerSoci-
etyisthesourcethatcomputingprofessionalstrusttoprovidehigh-quality,state-
of-the-artinformationonanon-demandbasis.TheComputerSocietyprovidesa
widerangeofforumsfortopmindstocometogether,includingtechnicalconfer-
ences,publications,andacomprehensivedigitallibrary,uniquetrainingwebinars,
professionaltraining,andtheTechLeaderTrainingPartnerProgramtohelporga-
nizationsincreasetheirstaff’stechnicalknowledgeandexpertise,aswellasthe
personalizedinformationtoolmyComputer.Tofindoutmoreaboutthecommu-
nityfortechnologyleaders,visithttp://www.computer.org.
IEEE/WileyPartnership
TheIEEEComputerSocietyandWileypartnershipallowstheCSPressauthored
book program to produce a number of exciting new titles in areas of computer
science,computing,andnetworkingwithaspecialfocusonsoftwareengineering.
IEEE Computer Society members continue to receive a 15% discount on these
titleswhenpurchasedthroughWileyoratwiley.com/ieeecs.
To submit questions about the program or send proposals, please contact Mary
Hatcher, Editor, Wiley-IEEE Press: Email: [email protected], Telephone:
201-748-6903, John Wiley & Sons, Inc., 111 River Street, MS 8-01, Hoboken,
NJ07030-5774.
DESIGNING PLATFORM
INDEPENDENT MOBILE
APPS AND SERVICES
ROCKY HECKMAN
Coverimage©gettyimages.com
Copyright©2016bytheIEEEComputerSociety,Inc.Allrightsreserved.
PublishedbyJohnWiley&Sons,Inc.,Hoboken,NewJersey.
PublishedsimultaneouslyinCanada.
Nopartofthispublicationmaybereproduced,storedinaretrievalsystem,ortransmittedinanyformor
byanymeans,electronic,mechanical,photocopying,recording,scanning,orotherwise,exceptas
permittedunderSection107or108ofthe1976UnitedStatesCopyrightAct,withouteithertheprior
writtenpermissionofthePublisher,orauthorizationthroughpaymentoftheappropriateper-copyfeeto
theCopyrightClearanceCenter,Inc.,222RosewoodDrive,Danvers,MA01923,(978)750-8400,fax
(978)750-4470,oronthewebatwww.copyright.com.RequeststothePublisherforpermissionshould
beaddressedtothePermissionsDepartment,JohnWiley&Sons,Inc.,111RiverStreet,Hoboken,NJ
07030,(201)748-6011,fax(201)748-6008,oronlineathttp://www.wiley.com/go/permission.
LimitofLiability/DisclaimerofWarranty:Whilethepublisherandauthorhaveusedtheirbesteffortsin
preparingthisbook,theymakenorepresentationsorwarrantieswithrespecttotheaccuracyor
completenessofthecontentsofthisbookandspecificallydisclaimanyimpliedwarrantiesof
merchantabilityorfitnessforaparticularpurpose.Nowarrantymaybecreatedorextendedbysales
representativesorwrittensalesmaterials.Theadviceandstrategiescontainedhereinmaynotbesuitable
foryoursituation.Youshouldconsultwithaprofessionalwhereappropriate.Neitherthepublishernor
authorshallbeliableforanylossofprofitoranyothercommercialdamages,includingbutnotlimitedto
special,incidental,consequential,orotherdamages.
Forgeneralinformationonourotherproductsandservicesorfortechnicalsupport,pleasecontactour
CustomerCareDepartmentwithintheUnitedStatesat(800)762-2974,outsidetheUnitedStatesat
(317)572-3993orfax(317)572-4002.
Wileyalsopublishesitsbooksinavarietyofelectronicformats.Somecontentthatappearsinprintmay
notbeavailableinelectronicformats.FormoreinformationaboutWileyproducts,visitourwebsiteat
www.wiley.com.
LibraryofCongressCataloging-in-PublicationData:
Names:Heckman,Rocky,author.
Title:Designingplatformindependentmobileappsandservices/Rocky
Heckman.
Description:Hoboken,NewJersey:JohnWiley&Sons,Inc.,[2016]|Includes
index.
Identifiers:LCCN2016009419|ISBN9781119060147(cloth)|ISBN9781119060185
(epub)|ISBN9781119060154(AdobePDF)
Subjects:LCSH:Mobilecomputing.|Cellphones–Programming.|Mobileapps.
Classification:LCCQA76.59.H432016|DDC005.25–dc23LCrecordavailableat
https://lccn.loc.gov/2016009419
PrintedintheUnitedStatesofAmerica.
10 9 8 7 6 5 4 3 2 1
Thankyoutoallmyfriends whofinallyconvincedmetowriteabook.
Mostofall,thankyoutomywifeStefanie,andmytwobeautiful girls
ElyssiaandKeirallifor notonlypushingmetofinish,butputting up
withallthetimeIspentdoingit.Iloveyouallverymuch.
LookDad,Ididit!
TABLE OF CONTENTS
LISTOFFIGURES xi
LISTOFTABLES xiii
PREFACE xv
ACKNOWLEDGMENTS xvii
CHAPTER1 THEMOBILELANDSCAPE 1
1.1 Introduction 1
1.2 PreviousAttemptsatCross-Platform 2
1.2.1 Java 2
1.2.2 EarlyWebApps 5
1.2.3 MultipleCodebases 7
1.3 BreadthVersusDepth 9
1.4 TheMulti-PlatformTargets 10
1.4.1 Traditional 10
1.4.2 Mobile 11
1.4.3 Wearables 12
1.4.4 Embedded 13
CHAPTER2 PLATFORM-INDEPENDENTDEVELOPMENTTECHNOLOGIES 15
TheGoldenRule 15
2.1 VendorLock-In 16
2.2 RecommendedStandardsandGuidelines 18
2.2.1 RespectingtheDevice 18
2.2.2 RespectingtheNetwork 19
2.2.3 CommunicationProtocols 21
2.2.4 DataFormats 31
2.2.5 MobileUserExperienceGuidelines 40
2.2.6 Authentication 45
2.2.7 DealingwithOfflineandPartiallyConnectedDevices 47
2.3 WrappingUp 63
CHAPTER3 PLATFORM-INDEPENDENTDEVELOPMENTSTRATEGY 64
3.1 High-LevelAppDevelopmentFlow 64
3.2 Five-LayerArchitecture 65
3.3 Five-LayerArchitectureDetail 66
3.3.1 TheUserInterfaceLayer 66
3.3.2 TheServiceInterfaceLayer 68
vii
viii CONTENTS
3.3.3 TheServiceLayer 69
3.3.4 TheDataAbstractionLayer 70
3.3.5 TheDataLayer 70
CHAPTER4 THEUSERINTERFACELAYER 72
4.1 PortingVersusWrapping 72
4.2 Multi-ClientDevelopmentTools 73
4.2.1 PhoneGap(http://phonegap.com/) 73
4.2.2 Xamarin(http://xamarin.com/) 74
4.2.3 Unity(http://www.unity3d.com) 75
4.2.4 VisualStudio 76
4.3 Cross-PlatformLanguages 76
4.4 AvoidWritingfortheLeastCommonDenominator 77
4.5 WrappingUp 78
CHAPTER5 THESERVICEINTERFACELAYER 79
5.1 MessageProcessing 79
5.1.1 PushversusPull 80
5.1.2 PartiallyConnectedScenarios 81
5.2 MessageProcessingPatterns 82
5.3 High-VolumeMessagingPatterns 85
5.3.1 QueueServicesandMicrosoftAzureEventHubs 86
5.3.2 WebSockets 89
5.4 High-VolumePushNotifications 91
5.4.1 ThirdPartyNotificationHubs 93
5.5 MessageTranslationandRouting 97
5.5.1 MessageTranslation 97
5.5.2 MessageRouting 103
5.5.3 HandlingLargeAmountsofData 108
5.6 WrappingUp 111
CHAPTER6 THESERVICELAYER 114
6.1 ThinkinginNodes 114
6.1.1 ScaleOutandScaleUp 114
6.1.2 ScaleOutversusScaleUp 114
6.2 PlanningforHorizontalScaling 117
6.2.1 NodeSizing 117
6.2.2 Statelessness 120
6.3 DesigningServiceLayersforMobileComputing 121
6.3.1 ServiceComponentization 122
6.4 ImplementationAbstraction 124
6.4.1 ServiceInterfaceAbstraction 124
6.5 UsingCQRS/ESforServiceImplementation 127
6.5.1 CQRSOverview 127
6.5.2 WhyCQRS 129
6.5.3 BeingAbletoSeparateDataModels 129
6.5.4 AggregatesandBoundedContexts 131
Description:Presents strategies to designing platform agnostic mobile apps connected to cloud based services that can handle heavy loads of modern computing.