The Mobile Architect The Mobile Architect Morgan Skinner Morgan Skinner
Jan 19, 2016
The Mobile ArchitectThe Mobile Architect
Morgan SkinnerMorgan Skinner
AgendaAgenda
Common Patterns and DesignsCommon Patterns and Designs Architecting Mobile ApplicationsArchitecting Mobile Applications
SynchronizationSynchronization Web ServicesWeb Services SQL CESQL CE MSMQMSMQ PerformancePerformance DeploymentDeployment
Common Patterns and Common Patterns and DesignsDesigns Document tested simple mechanismsDocument tested simple mechanisms Provide common terminology for Provide common terminology for
architects and developersarchitects and developers PromotePromote
Re-useRe-use FlexibilityFlexibility CohesionCohesion
Defining SOADefining SOA
Service-Oriented Architecture is an approach to Service-Oriented Architecture is an approach to organizing information technology in which data, organizing information technology in which data, logic, and infrastructure resources are accessed by logic, and infrastructure resources are accessed by routing messages between network interfacesrouting messages between network interfaces
Basic value proposition is to provide consistent, Basic value proposition is to provide consistent, stable interfaces in front of diverse or volatile stable interfaces in front of diverse or volatile implementationsimplementations Establish context for information exchange across Establish context for information exchange across
organizationsorganizations Encapsulate complexity within organizationsEncapsulate complexity within organizations Enable context-sensitive information processingEnable context-sensitive information processing
Microsoft’s Vision for SOAMicrosoft’s Vision for SOA
Service orientation will encapsulate and Service orientation will encapsulate and componentize processes and systemscomponentize processes and systems Help manage complexityHelp manage complexity Permit controlled changePermit controlled change Support continuous improvementSupport continuous improvement
Business capabilities and business processes will Business capabilities and business processes will be modeled as servicesbe modeled as services Organizations will expose touchpoints into these Organizations will expose touchpoints into these
processes to both internal and extra-organizational actorsprocesses to both internal and extra-organizational actors Allows automation of processes that have defied Allows automation of processes that have defied
automation until nowautomation until now
On the path to the Agile EnterpriseOn the path to the Agile Enterprise
Three Tier Three Tier PatternPattern
Business LayerBusiness Layer
Data Access LayerData Access Layer
Presentation LayerPresentation LayerOrder Entry Web Pages
Reporting Web Pages
Order Manageme
nt
Reporting Manageme
nt
User Manageme
nt
ADO.NETOrderData
Access
Reporting Data
Access
Service Orientated Service Orientated ArchitectureArchitecture
Business LayerBusiness Layer
Data Access LayerData Access Layer
Presentation LayerPresentation LayerOrder Entry Web Pages
Reporting Web Pages
Order Manageme
nt
Reporting Manageme
nt
User Manageme
nt
ADO.NETOrderData
Access
Reporting Data
Access
Service Interfaces
ServicesServices
Secu
rity
Mobile ArchitecturesMobile Architectures
Need to addressNeed to address CommunicationCommunication
From device to server or deviceFrom device to server or device
SecuritySecurity Are communications secure?Are communications secure? Is data secured?Is data secured?
PerformancePerformance DeploymentDeployment
All of the above can impact physical All of the above can impact physical and logical Designsand logical Designs
Server ApplicationsServer Applications
Supports large number of devicesSupports large number of devices Low cost deploymentLow cost deployment Centralized logicCentralized logic Online onlyOnline only Browser user interfaceBrowser user interface
ASP.NETASP.NET
Mobile Web Pages
HTML for Pocket IEHTML for Pocket IE
WML for WAP BrowsersWML for WAP Browsers
Client ApplicationsClient Applications
Targets a SmartclientTargets a Smartclient Deployment requiredDeployment required Can work disconnectedCan work disconnected Rich user interfaceRich user interface
ServerServerWeb Services
HTTP ChannelHTTP Channel
MSMQ
Online / OfflineOnline / Offline
Smartclient applications need to Smartclient applications need to support online / offlinesupport online / offline
Synchronization OptionsSynchronization Options One / Both waysOne / Both ways Application / Database levelApplication / Database level
SynchronizationSynchronization
Consider your applications requirementsConsider your applications requirements Both WaysBoth Ways
Multi-user updates of dataMulti-user updates of data Web ServicesWeb Services SQL CE ReplicationSQL CE Replication
One WayOne Way Mutually exclusive dataMutually exclusive data Web ServicesWeb Services MSMQMSMQ SQL CE Remote Data AccessSQL CE Remote Data Access SMSSMS
SynchronizationSynchronization
ApplicationApplication
User Interface
Application Logic
SQL Server CEDataData
SyncSyncApplication SyncApplication Sync Data SyncData Sync
High reuse of logicHigh reuse of logic
Slower synchronizationSlower synchronization
Fast synchronizationFast synchronization
Low level of logicLow level of logic
Data collisionsData collisions
Data Access LayerData Access Layer
Business LayerBusiness Layer
Web Web ServicesServices UIUI
ApplicationApplication
SyncSync
Detecting Online / Detecting Online / OfflineOffline
Web ServicesWeb Services SynchronousSynchronous
Good for small, quick packets of dataGood for small, quick packets of data Block the current threadBlock the current thread
AsynchronousAsynchronous Good for larger packets of dataGood for larger packets of data Callback when processing finishedCallback when processing finished Check for exceptions due to connectivity issuesCheck for exceptions due to connectivity issues
SecuritySecurity Recommended to use SSLRecommended to use SSL Digest or Clear Text authenticationDigest or Clear Text authentication Currently no support for WSECurrently no support for WSE Custom via SOAP headersCustom via SOAP headers
Web Services ConsiderationsWeb Services Considerations
Store and ForwardStore and Forward Web service requests cachedWeb service requests cached Executed when network availableExecuted when network available Variable re-try algorithmVariable re-try algorithm
Data CompressionData Compression GSM data costsGSM data costs Conserve bandwidthConserve bandwidth
Smart connected architectureSmart connected architecture
Custom WS ProxyCustom WS Proxy
Network Test
Store and Forward
SmartClient ApplicationSmartClient Application
Web ServiceWeb Service
StoreStore
AsynchronouAsynchronous Timed s Timed EventEvent
WebRequestCompleted
Order Service
Map Service
Data CompressionData Compression Server sideServer side
Windows 2003 ServerWindows 2003 Server Enable compression and gzip.dll via MMCEnable compression and gzip.dll via MMC Modify metabase adding asmx to Modify metabase adding asmx to
HcScriptFileExtensions for gzip and HcScriptFileExtensions for gzip and deflate compression filtersdeflate compression filters
Client sideClient side Need to override GetWebRequest and Need to override GetWebRequest and
GetWebResponseGetWebResponse .NET Compact Framework SP1.NET Compact Framework SP1
Client applications need some Client applications need some additional coding to be able to exploit. additional coding to be able to exploit.
Client Data CompressionClient Data Compression
public class GzipProxy : SoapHttpClientProtocolpublic class GzipProxy : SoapHttpClientProtocol{{
protected override WebRequest GetWebRequest(System.Uri uri)protected override WebRequest GetWebRequest(System.Uri uri){{
WebRequest req = base.GetWebRequest(uri);WebRequest req = base.GetWebRequest(uri);
req.Headers.Add("Accept-Encoding", "gzip, deflate");req.Headers.Add("Accept-Encoding", "gzip, deflate");return req;return req;
}}
protected override WebResponse GetWebResponse(WebRequest protected override WebResponse GetWebResponse(WebRequest req)req){{
return new CompressedHttpWebResponse(req);return new CompressedHttpWebResponse(req);}}
}}
Web ServicesWeb Services Store and Forward Store and Forward
DataSetsDataSets
Supported by Web servicesSupported by Web services Typed DataSet unsupportedTyped DataSet unsupported Serializable to XMLSerializable to XML Missing Merge() and GetChanges()Missing Merge() and GetChanges() Manual synchronization requiredManual synchronization required
SQL Server CE 2.0SQL Server CE 2.0
Runs on Pocket PC 2000+Runs on Pocket PC 2000+ Smartphone version comingSmartphone version coming 1.5MB memory footprint1.5MB memory footprint Compact Framework SupportCompact Framework Support Authentication and EncryptionAuthentication and Encryption ConnectivityConnectivity
Remote Data Access - SQL7/2000Remote Data Access - SQL7/2000 Merge Synchronization – SQL2000Merge Synchronization – SQL2000
Database Feature SetDatabase Feature SetRich functionality for small footprintRich functionality for small footprint Multi-column indexesMulti-column indexes Referential integrityReferential integrity Sub-selects (IN)Sub-selects (IN) DefaultsDefaults Inner/outer joinsInner/outer joins One file databaseOne file database Null supportNull support Unicode supportUnicode support TransactionsTransactions
Data-typesData-types Real, Numeric, NVarChar, Real, Numeric, NVarChar,
NText, Image, Integer, NText, Image, Integer, DateTime, VarBinary, DateTime, VarBinary, UniqueIdentifier, MoneyUniqueIdentifier, Money
Having/group byHaving/group by Seek on indexSeek on index Set functionsSet functions Identity attributeIdentity attribute Local security - DB Local security - DB
encryption (128bit) and encryption (128bit) and database passworddatabase password
OLEDB CEOLEDB CE
CLR / .NET CFCLR / .NET CF
QP/Cursor Engine/ES QP/Cursor Engine/ES
CE Data AccessCE Data AccessStorage ArchitectureStorage Architecture
Client Client Agent: Agent:
ReplicationReplicationandandRDARDA
ADO ADO CE CE v3.1v3.1
OLEDB / OLEDB / Replication APIReplication API
IISIIS
CLIENTCLIENT SERVERSERVER
Storage Engine / Repl Storage Engine / Repl TrackingTracking
SQL CE Edition v2.0SQL CE Edition v2.0
eVB eVB 3.03.0 eVC eVC
3.03.0
OLEDBOLEDB
OLEDBOLEDB
Server Server Agent: Agent:
ReplicationReplicationandand
Remote Remote Data Data
AccessAccess
HTTPHTTP
XML/BizTalk/CS 2002XML/BizTalk/CS 2002
802.11b, 802.11b, CDPD, CDPD, GSM, GSM,
CDMA, CDMA, TDMA, etc.TDMA, etc.
Enterprise BackendEnterprise Backend
Oracle / db2 / etcOracle / db2 / etc
SQL Server SQL Server CE Data CE Data ProviderProvider
Native/UnmanagedNative/Unmanaged StackStack
Data ProviderData Provider
SQL Server SQL Server Client Data Client Data Provider Provider
ADO.NETADO.NET
VS .NET (VB.NET, C#)VS .NET (VB.NET, C#).NET CF / Managed.NET CF / Managed StackStack
TDSTDS
EthernetEthernet
Well Well ConnectedConnected
Occasionally Occasionally ConnectedConnected
Remote Data Access (RDA)Remote Data Access (RDA)
Remote Data Access (RDA)Remote Data Access (RDA)
Remote Data AccessRemote Data Access
Merge ReplicationMerge Replication
Based on SQL Server 2000 bi-Based on SQL Server 2000 bi-directional implementationdirectional implementation
Ideal for mobile useIdeal for mobile use Update data on client and/or serverUpdate data on client and/or server Merge and resolve conflict based on Merge and resolve conflict based on
server-side rulesserver-side rules Easy synchronization when connectedEasy synchronization when connected
Flexible data partitioning: vertical, Flexible data partitioning: vertical, horizontal, and dynamichorizontal, and dynamic
Anonymous pull subscriptionsAnonymous pull subscriptions Auto Ranged Identity SupportAuto Ranged Identity Support
SQL CE ReplicationSQL CE Replication
DataSet vs SQL CEDataSet vs SQL CE
DataSetDataSet SQL CESQL CE
Inbuilt to Compact FrameworkInbuilt to Compact Framework Need to deployNeed to deploy
Extra runtime RAM requirementExtra runtime RAM requirement
Limited filter capabilityLimited filter capability Rich ANSI SQL supportRich ANSI SQL support
Serializable to XMLSerializable to XML Persists on filesystemPersists on filesystem
Supports Web servicesSupports Web services Remote data access and Remote data access and synchronization over HTTPsynchronization over HTTP
Works with .NET RuntimeWorks with .NET Runtime Requires SQL ServerRequires SQL Server
Performance limited to smaller Performance limited to smaller datadata
Large databases up to 2GBLarge databases up to 2GB
No inbuilt securityNo inbuilt security 128-bit Encryption support128-bit Encryption support
Client Access LicensingClient Access Licensing
Microsoft Message QueueMicrosoft Message Queue
Message QueueMessage Queue
MSMQMSMQ
Implements asynchronous Implements asynchronous communicationscommunications
Provides guaranteed delivery, efficient Provides guaranteed delivery, efficient routing, priority based messaging.routing, priority based messaging.
Usernames storage support roamingUsernames storage support roaming NIC trackingNIC tracking Transparent, salvageable storageTransparent, salvageable storage Small footprint ~150KBSmall footprint ~150KB Support for private queues onlySupport for private queues only
Communication OptionsCommunication OptionsTransportTransport SummarySummary
Web ServicesWeb Services Internet ReadyInternet Ready
Industry standards / High level of interoperabilityIndustry standards / High level of interoperability
Highly extensibleHighly extensible
Application synchronizationApplication synchronization
SQL CESQL CE Internet ReadyInternet Ready
Designed for data manipulationDesigned for data manipulation
Synchronization EnabledSynchronization Enabled
Can communicate to SQL ServerCan communicate to SQL Server
SecureSecure
(Smartphone support coming)(Smartphone support coming)
MSMQMSMQ Guaranteed deliveryGuaranteed delivery
Extension of backend MSMQ systemsExtension of backend MSMQ systems
Network tracking built inNetwork tracking built in
(Managed support coming)(Managed support coming)
Other ConsiderationsOther Considerations
PerformancePerformance Raw ApplicationRaw Application Perceived ResponsePerceived Response Backend ServersBackend Servers
Security & DeploymentSecurity & Deployment See See Securing and Deploying your Mobile Securing and Deploying your Mobile
ApplicationApplication
Performance - WinFormsPerformance - WinForms
Load and cache Forms in the backgroundLoad and cache Forms in the background Populate data separate from Form.Show()Populate data separate from Form.Show()
Pre-populate data, orPre-populate data, or Load data async to Form.Show()Load data async to Form.Show()
Parent controls top-downParent controls top-down e.g. Form e.g. Form panels panels controls controls
Keep event handling code tightKeep event handling code tight Process bigger operations asynchronouslyProcess bigger operations asynchronously BlockingBlocking in event handlers will affect UI in event handlers will affect UI
responsivenessresponsiveness
Performance - XMLPerformance - XML Use XmlTextReader and XmlTextWriterUse XmlTextReader and XmlTextWriter
Smaller memory footprint than using Smaller memory footprint than using XmlDocumentXmlDocument
XmlTextReader is a pull model parser XmlTextReader is a pull model parser which only reads a “window” of the datawhich only reads a “window” of the data
Design XML schema first, then codeDesign XML schema first, then code Understand the structure of your XML Understand the structure of your XML
documentdocument Use elements to groupUse elements to group
Allows use of Skip() in XmlTextReaderAllows use of Skip() in XmlTextReader
Use attributes to reduce sizeUse attributes to reduce size
Performance - DataPerformance - Data
If data is local…instead of DataSet…If data is local…instead of DataSet… Leverage SQL CE native in-proc databaseLeverage SQL CE native in-proc database Query data using DataReaderQuery data using DataReader Use TableDirect command type for fast index searchesUse TableDirect command type for fast index searches
Equivalent to “Equivalent to “SELECT * FROM SELECT * FROM foofoo”” Limit open SqlCeCommand/DataReadersLimit open SqlCeCommand/DataReaders
Dispose when completeDispose when complete
If data is remote…If data is remote… Use SQL CE replicationUse SQL CE replication When using Web ServicesWhen using Web Services
Save data locally in SQL CE for faster access and storageSave data locally in SQL CE for faster access and storage Don’t save remote DataSets as XML to deviceDon’t save remote DataSets as XML to device
If you do, save Schema as wellIf you do, save Schema as well
Performance - ServerPerformance - Server
Aggregate multiple Web service calls Aggregate multiple Web service calls where possiblewhere possible
Stress test the server, find your limitsStress test the server, find your limits Implement stateless calls for web Implement stateless calls for web
farmsfarms For large user base, partition times For large user base, partition times
users can replicate SQL datausers can replicate SQL data
Deployment Deployment ConsiderationsConsiderations
InstallationInstallation CAB format for installationCAB format for installation
Desktop ActiveSyncDesktop ActiveSync Web page URLWeb page URL EmailEmail Service Indication / Service Loading MessagesService Indication / Service Loading Messages SD/CF CardSD/CF Card
What is user base?What is user base?
OngoingOngoing How to ensure users are running latest How to ensure users are running latest
versions?versions?
SummarySummary Store and Forward connectivity can help Store and Forward connectivity can help
connected/disconnected environmentconnected/disconnected environment Web ServicesWeb Services
StandardisedStandardised ExtensibleExtensible
SQL CESQL CE Designed for data manipulationDesigned for data manipulation SecureSecure
MSMQMSMQ Extension of backend MSMQ systemsExtension of backend MSMQ systems Guaranteed deliveryGuaranteed delivery
Design with performance in mindDesign with performance in mind
ResourcesResources
Patterns & PracticesPatterns & Practiceshttp://www.microsoft.com/resources/practices/http://www.microsoft.com/resources/practices/
.NET Compact Framework FAQ.NET Compact Framework FAQhttp://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspxdefault.aspx
SharpZipLib Compression Library (note licensing)SharpZipLib Compression Library (note licensing)http://http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspxwww.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx
IIS 6.0 HTTP CompressionIIS 6.0 HTTP Compression
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/phttp://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/windowsserver2003/maintain/operate/iis6perf.asprodtechnol/windowsserver2003/maintain/operate/iis6perf.asp
SQL CE and SQL 2000 sp3aSQL CE and SQL 2000 sp3ahttp://www.microsoft.com/sql/ce/downloads/sp3.asphttp://www.microsoft.com/sql/ce/downloads/sp3.asp
MSMQMSMQhttp://msdn.microsoft.com/msdnmag/issues/01/12/MSMQCE/default.aspxhttp://msdn.microsoft.com/msdnmag/issues/01/12/MSMQCE/default.aspx
© 2003-2004 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.