30

Developing Mobile Applications Tim Heuer [email protected] Bert Solano [email protected]

Embed Size (px)

Citation preview

Developing Mobile ApplicationsDeveloping Mobile Applications

Tim HeuerTim [email protected]@immedient.com

Bert SolanoBert [email protected]@immedient.com

AgendaAgenda

Mobile OverviewMobile Overview VS .NET FeaturesVS .NET Features Data Storage OptionsData Storage Options Tips and TricksTips and Tricks

CE Devices are availableCE Devices are available

Mobile vs. WirelessMobile vs. Wireless Mobile ArchitecturesMobile Architectures

Application can function in a vacuumApplication can function in a vacuum ““Synchronize When You Can”Synchronize When You Can”

WirelessWireless Tethered to the data source, just like Tethered to the data source, just like

wired, only we use wirelesswired, only we use wireless WiFi, CDPD, GPRS,WiFi, CDPD, GPRS,

Prone to problemsProne to problems

Mobile Apps leverage WirelessMobile Apps leverage Wireless Wireless is NOT MobileWireless is NOT Mobile

Goal for a Mobile AppGoal for a Mobile App

Can your user function from the Can your user function from the bottom of the ocean? bottom of the ocean? (… with a waterproof device)(… with a waterproof device)

Is your application as reliable as their Is your application as reliable as their paper notebook?paper notebook?

Take advantage of the internet, don’t Take advantage of the internet, don’t depend on it.depend on it.

Compatibility ChallengesCompatibility Challenges Many different device typesMany different device types

Different form-factorsDifferent form-factors Human interface choicesHuman interface choices Connectivity choicesConnectivity choices

WiFiWiFi Network CradleNetwork Cradle Compact Compact FlashFlash

WWanWWan Desktop CradleDesktop Cradle Infra RedInfra Red

On-device resources vary widelyOn-device resources vary widely ROM/RAM capacityROM/RAM capacity File systemFile system Battery lifeBattery life

Mobile DevelopmentMobile DevelopmentEnvironmentEnvironment

Single set of familiar Single set of familiar productive tools for all productive tools for all developmentdevelopment

Server componentsServer componentsRich client applicationsRich client applicationsMobile Web developmentMobile Web developmentBuilding Web servicesBuilding Web servicesConsuming Web servicesConsuming Web services

Easily take advantage of Easily take advantage of all Microsoft mobile all Microsoft mobile platform assets platform assets

Mobile DevelopmentMobile DevelopmentApproachesApproaches

Application Application on deviceon device

Device specificDevice specific Fewer devicesFewer devices

Application Application on serveron server

Runs in browserRuns in browser Many devicesMany devices

Offline optionsOffline options Richest UIRichest UI

Online onlyOnline only Less UI choiceLess UI choice Easy to deployEasy to deploy

Client Client ApplicationApplication

WebWebApplicationApplication

Mobile DevelopmentMobile DevelopmentToolsTools

Client Client ApplicationApplication

WebWebApplicationApplication

Embedded Embedded Visual ToolsVisual Tools

eVB and eVC++eVB and eVC++

Device-specific Device-specific Active Server Active Server

PagesPages

Visual Studio Visual Studio & .NE& .NE

T Compact T Compact FrameworkFramework

Visual Studio & Visual Studio & Mobile Internet Mobile Internet

ToolkitToolkit

TodayToday

Mobile Internet ToolkitMobile Internet Toolkit

ComponentsComponents Mobile controlsMobile controls Mobile designerMobile designer Rich device identificationRich device identification

Rapidly develop Mobile Web Rapidly develop Mobile Web ApplicationsApplications

Powerful and flexiblePowerful and flexible Easy to customize and extendEasy to customize and extend

For future devicesFor future devices

Mobile ControlsMobile Controls Render based on device capabilitiesRender based on device capabilities Automatically output multiple markup Automatically output multiple markup

languageslanguages Built upon ASP.NET control base Built upon ASP.NET control base

classesclasses Common controls:Common controls:

LabelLabel TextViewTextView LinkLink CalendarCalendar

.NET Compact Framework.NET Compact Framework Smart Device ExtensionsSmart Device Extensions A subset of the .NET Framework A subset of the .NET Framework

Same programming modelSame programming model Same security as desktop programming modelSame security as desktop programming model

Lightweight and Resource EfficientLightweight and Resource Efficient RAMRAM Battery and CPU usageBattery and CPU usage Flash and ROMFlash and ROM

Rich PocketPC FunctionalityRich PocketPC Functionality Windows Forms (WinForms)Windows Forms (WinForms) ADO.NET Data AccessADO.NET Data Access XML Web Services ClientXML Web Services Client

With Windows CEWith Windows CE

Windows UIWindows UI Standard Windows look and feelStandard Windows look and feel Forms-based UIForms-based UI All the standard controlsAll the standard controls Significant subset for small sizeSignificant subset for small size

XML Web Services XML Web Services Windows NTWindows NT®® network integration network integration

Data AccessData Access Local data (offline)Local data (offline) Remote data (online)Remote data (online) Simple structured files (text)Simple structured files (text)

Take advantage of Windows richnessTake advantage of Windows richness

Windows CE DeviceWindows CE Device

Base Class LibraryBase Class Library

Data and XMLData and XML

XML WebXML WebServicesServices

WindowsWindowsFormsForms

Common Language RuntimeCommon Language Runtime

Device CompatibilityDevice Compatibility

.Net Compact Framework.Net Compact Framework Faithful implementation of Standard CLIFaithful implementation of Standard CLI Core types and methods + device Core types and methods + device

extensionsextensions Subset of .Net framework appropriate to Subset of .Net framework appropriate to

smart device developmentsmart device development

ISO/IEC 23271:2002 / ECMA 335

Common Language Infrastructure

Microsoft .NET Compact Framework Pocket PC (CE)

Microsoft Windows CE ExtensionsIRDA, Barcode Scanner, etc

Microsoft .NET Compact Framework

Smart Phone

Microsoft Full .NET Framework Desktop

It’s All About BalanceIt’s All About Balance (Developer Perspective) (Developer Perspective)

FeaturesFeatures Amount of DataAmount of Data Garbage CollectionGarbage Collection Data Entry/SelectionData Entry/Selection

PerformancePerformance Memory UsageMemory Usage

Data, ObjectsData, Objects

ConnectivityConnectivity

This is NOT the desktopThis is NOT the desktop, , think 100mhzthink 100mhz

Device DatabasesDevice Databases

Microsoft StrategyMicrosoft StrategyScalable SolutionsScalable Solutions

Scalable SolutionsScalable Solutions

MSDE

SQL Server CE

SQL Server

}}Server, Server, Desktop,Desktop,Tablet PCTablet PC

CE PlatformCE Platform

SQL Server CE SQL Server CE (SQL CE)(SQL CE) Database for the CE / Pocket PC PlatformDatabase for the CE / Pocket PC Platform Similar programming style to SQL ServerSimilar programming style to SQL Server Limitations are more device then SQL/CELimitations are more device then SQL/CE 1 Connection/ Database, 1 Connection/ Database, (usually not a problem)(usually not a problem) Multiple Databases per deviceMultiple Databases per device No Stored procsNo Stored procs

Use cached DataCommandsUse cached DataCommands Referential Integrity with cascading updates/DeletesReferential Integrity with cascading updates/Deletes Stand alone, or replicate/sync with SQL ServerStand alone, or replicate/sync with SQL Server

SQL Server not required, SQL Server not required, but best matchbut best match SQL Server CE 2.0 designed for .NET Compact SQL Server CE 2.0 designed for .NET Compact

Framework Framework (System.Data.SqlServerCe)(System.Data.SqlServerCe) Replacement of Pocket Access, Replacement of Pocket Access, just like DBF/Accessjust like DBF/Access

CE Data Access Storage ArchitectureCE Data Access Storage Architecture

OLEDB CEOLEDB CE

CLR / .NET CFCLR / .NET CF

QP/Cursor Engine/ES QP/Cursor Engine/ES

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

802.11b, 802.11b, CDPD, CDPD, GSM, GSM,

CDMA, CDMA, TDMA, etc.TDMA, 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 / ManagedNET CF / Managed StackStack

TDSTDS

EthernetEthernet

Well Well ConnectedConnected

Occasionally Occasionally ConnectedConnected

Setting up SQL Setting up SQL CE ReplicationCE Replication Basic Replication setup +Basic Replication setup + Install SQL CE Replication ToolsInstall SQL CE Replication Tools

http://www.microsoft.com/sql/downloads/ce/sp3.asphttp://www.microsoft.com/sql/downloads/ce/sp3.asp

Test connectivity from deviceTest connectivity from device Localhost won’t workLocalhost won’t work NETBIOS name may not work NETBIOS name may not work (WINS Resolution)(WINS Resolution)

Test with IP or Fully Qualified Domain Name Test with IP or Fully Qualified Domain Name If you don’t get this response from the DLL, don’t go any furtherIf you don’t get this response from the DLL, don’t go any further

http://192.168.1.100/Repll/sscesa20.dllhttp://192.168.1.100/Repll/sscesa20.dll

SQL / CE – Data TransferSQL / CE – Data Transfer

Multiple TechniquesMultiple Techniques RDARDA

system.Data.SqlServerCe.SqlCeRemoteDataAccesssystem.Data.SqlServerCe.SqlCeRemoteDataAccess Great for semi-connected environments, large data Great for semi-connected environments, large data

transferstransfers Merge Replication Over IISMerge Replication Over IIS System.Data.SqlServerCe.SqlCeReplicationSystem.Data.SqlServerCe.SqlCeReplication

Great for managing concurrencyGreat for managing concurrency ADO.netADO.net System.Data.SqlClient.SqlCommandSystem.Data.SqlClient.SqlCommand

Can call SQL Server directly, but not a great idea…* Can call SQL Server directly, but not a great idea…* (*Not (*Not a Mobile Architecture)a Mobile Architecture)

Web ServicesWeb Services Great when concurrency isn’t an issue, or server isn’t SQLGreat when concurrency isn’t an issue, or server isn’t SQL

Supported ADO .NET And XML Supported ADO .NET And XML Classes On .NET CFClasses On .NET CF

XmlWriterXmlWriter

DataSetDataSet

XmlDocumentXmlDocument

.NET Data.NET Data Provider Provider for SQL Serverfor SQL ServerXML FileXML File

SqlConnectionSqlConnection

SqlDataAdapterSqlDataAdapter

SqlCommandSqlCommand

XmlReaderXmlReader

.NET Data Provider .NET Data Provider for SQL CEfor SQL CE

SqlCeConnectionSqlCeConnection

SqlCeDataAdapterSqlCeDataAdapter

SqlCeCommandSqlCeCommand

DataViewDataView

SqlDataReaderSqlDataReader SqlCeDataReaderSqlCeDataReader

Parsing ExceptionsParsing Exceptionspublic static void ShowErrors(SqlCeException se) { SqlCeErrorCollection errorCollection = se.Errors; StringBuilder exInfo= new StringBuilder(); Exception inner = se.InnerException; foreach (SqlCeError err in errorCollection) { exceptionDetailStringBuilder.Append("\n Error Code: " + err.HResult.ToString("X")); exceptionDetailStringBuilder.Append("\n Message : " + err.Message); exceptionDetailStringBuilder.Append("\n Minor Err.: " + err.NativeError); exceptionDetailStringBuilder.Append("\n Source : " + err.Source); foreach (int numPar in err.NumericErrorParameters) { if (0 != numPar) exceptionDetailStringBuilder.Append("\n Num. Par. : " + numPar); } foreach (string errPar in err.ErrorParameters) { if (String.Empty != errPar) exceptionDetailStringBuilder.Append("\n Err. Par. : " + errPar); } MessageBox.Show(exceptionDetailStringBuilder.ToString()); exceptionDetailStringBuilder.Remove(0, exceptionDetailStringBuilder.Length); }}

Mobile ApplicationMobile Application

Tips and TricksTips and Tricks Always think Performance, Always think Performance, ……alwaysalways

Test performance on everythingTest performance on everything Get the actual deviceGet the actual device Design and Proof of Concept Design and Proof of Concept

EVERYTHINGEVERYTHING Get a wireless Lan for debuggingGet a wireless Lan for debugging Reuse everything you canReuse everything you can Database optimization is KEYDatabase optimization is KEY

Don’t assume flat is good. Balance of Don’t assume flat is good. Balance of normalization is goodnormalization is good

Don’t assume your .sdf needs to have the Don’t assume your .sdf needs to have the same structure as the serversame structure as the server

Tips and TricksTips and Tricks

This is NOT a 1.8GHZ ProcessorThis is NOT a 1.8GHZ Processor Think 100MHZThink 100MHZ

Be kind to your environmentBe kind to your environment Reuse EverythingReuse Everything

Pre-Load DataPre-Load Data Use DataSets to cache data Use DataSets to cache data …more to come……more to come…

Save Forms that will be used againSave Forms that will be used again Use a forms collection that caches formsUse a forms collection that caches forms

Toss objects that you don’t use oftenToss objects that you don’t use often Don’t try to load 9 MB of data onto a device Don’t try to load 9 MB of data onto a device

with 8 MB of RAMwith 8 MB of RAM

protected override void OnClosing(CancelEventArgs e){ this.Save(); e.Cancel = true; this.Hide(); base.OnClosing (e);}

ResourcesResources Newsgroups:Newsgroups:

microsoft.public.dotnet.framework.compactframeworkmicrosoft.public.dotnet.framework.compactframework

http://www.gotdotnet.com/team/netcfhttp://www.gotdotnet.com/team/netcf SQL CE SQL CE

http://www.microsoft.com/sql/ce/http://www.microsoft.com/sql/ce/ http://www.microsoft.com/sql/ce/techinfo/http://www.microsoft.com/sql/ce/techinfo/

default.aspdefault.asp Article on Setting up a sample Replication and Article on Setting up a sample Replication and

RDARDAhttp://msdn.microsoft.com/library/default.asp?http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsqlce/html/sqlwince.aspurl=/library/en-us/dnsqlce/html/sqlwince.asp

Q & AQ & A