the top tips you need to learn about data in your mobile app

43
The Top Reasons You Need to Learn about Data Before you Develop Your Mobile App CHRIS WOODRUFF

Upload: woodruff-solutions-llc

Post on 16-Jan-2017

617 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: The Top Tips You need to Learn about Data in your Mobile App

The Top Reasons You Need to Learn about

Data Before you Develop Your Mobile AppCHRIS WOODRUFF

Page 2: The Top Tips You need to Learn about Data in your Mobile App

Chris Woodruff

[email protected]

SKYPEcwoodruff

TWITTERcwoodruff

PHONE616.724.6885

Page 3: The Top Tips You need to Learn about Data in your Mobile App
Page 4: The Top Tips You need to Learn about Data in your Mobile App

AgendaThe Top Reasons You Need to Learn about Data in Your Windows Phone App

://HTTP

1 UNDERSTAND HTTPPROTOCOL

WEB

SERVICES 2 UNDERSTAND WEB SERVICES

REST

3 UNDERSTAND REST

DATA

CACHING4 KNOW HOW TO CACHE DATA

IN THE APP

MVVM

5 PICK AND USE A GOOD MVVMFRAMEWORK

DATAVIZ

6 LEARN HOW TO SHOWDATA IN YOUR APP

Page 5: The Top Tips You need to Learn about Data in your Mobile App

UNDERSTAND HTTP PROTOCOLThe Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 6: The Top Tips You need to Learn about Data in your Mobile App
Page 7: The Top Tips You need to Learn about Data in your Mobile App

WHAT SHOULD YOU KNOW ABOUT HTTP?

Resources These are the URLs you use to get to pages on the web

Request HeadersThese are additional instructions that are sent with the request. These might define what type of response is required or authorization details.

Request VerbsThese describe what you want to do with the resource. A browser typically issues a GET verb to instruct the endpoint it wants to get data, however there are many other verbs available including things like POST, PUT and DELETE.

Request Body

Data that is sent with the request. For example a POST (creation of a new

item) will required some data which is typically sent as the request body in

the format of JSON or XML.

Response Body

This is the main body of the response. If the request was to a web server, this

might be a full HTML page.

Response Status codes

These codes are issues with the response and give the client details on

the status of the request.

The Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 8: The Top Tips You need to Learn about Data in your Mobile App

HOW DOES HTTP WORK?

GET CODEMASH.COM

http://www.codemash.com/index.html

WHAT DOES THE BROWSER DO?

GET /index.html HTTP/1.0From: [email protected]: HTTPTool/1.0[blank line here]

WHAT IS THE RESPONSE?HTTP/1.0 200 OKDate: Thu, 8 Jan 2015 3:30:00 GMTContent-Type: text/htmlContent-Length: 1354

<html><body></body></html>

The Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 9: The Top Tips You need to Learn about Data in your Mobile App

HTTP VERBS

GETRequests a representation of the specified resource. Requests using GET should only

retrieve data and should have no other effect.

HEADAsks for the response identical to the one that would correspond to a GET request, but without the response body.

POSTRequests that the server accept the entity

enclosed in the request as a new subordinate of the web resource identified

by the URI.

PUTRequests that the enclosed entity be stored under the supplied URI.

DELETEDeletes the specified resource. PATCH

Applies partial modifications to a resource

The Top Reasons You Need to Learn about Data in Your Windows Phone App

TRACEEchoes back the received request so that a client can see what (if any) changes or

additions have been made by intermediate servers.

OPTIONSReturns the HTTP methods that the server supports for the specified URL.

Page 10: The Top Tips You need to Learn about Data in your Mobile App

HTTP RESONSE CODES

1XXRequest received, continuing process.

This class of status code indicates a provisional response, consisting only of

the Status-Line and optional headers, and is terminated by an empty line.

2XXThis class of status codes indicates the action requested by the client was received, understood, accepted and processed successfully.

3XXThis class of status code indicates the

client must take additional action to complete the request.

4XXThe 4xx class of status code is intended for cases in which the client seems to have errored.

5XXThe server failed to fulfill an apparently

valid request.

Response status codes beginning with the digit "5" indicate cases in which the server

is aware that it has encountered an error or is otherwise incapable of performing

the request.

The Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 11: The Top Tips You need to Learn about Data in your Mobile App

COMMON HTTP RESONSE CODESThe Top Reasons You Need to Learn about Data in Your Windows Phone App

101 Switching Protocols - Tells the client that the server will switch protocols to that specified in the Upgrade message header field during the current connection. For example, when requesting a page, a browser might receive a status code of 101, followed by an "Upgrade" header showing that the server is changing to a different version of HTTP.

200 OK - The request sent by the client was successful.202 Accepted - The request has been accepted for processing, but has not yet been processed.204 No Content - The request was successful but does not require the return of an entity-body.

301 Moved Permanently - The resource has permanently moved to a different URI.302 Found - The requested resource has been found under a different URI but the client should continue to use the original URI.303 See Other - The requested response is at a different URI and should be accessed using a GET command at the given URI.304 Not Modified - The resource has not been modified since the last request.

Page 12: The Top Tips You need to Learn about Data in your Mobile App

COMMON HTTP RESONSE CODESThe Top Reasons You Need to Learn about Data in Your Windows Phone App

400 Bad Request - The syntax of the request was not understood by the server.401 Not Authorized - The request needs user authentication.403 Forbidden - The server has refused to fulfill the request.404 Not Found - The document/file requested by the client was not found.405 Method Not Allowed - The method specified in the Request-Line is not allowed for the specified resource.407 Proxy Authentication Required - The request first requires authentication with the proxy.

500 Internal Server Error - The request was unsuccessful due to an unexpected condition encountered by the server.502 Bad Gateway - The server received an invalid response from the upstream server while trying to fulfill the request.503 Service Unavailable - The request was unsuccessful due to the server being down or overloaded.504 Gateway Timeout - The upstream server failed to send a request in the time allowed by the server.

Page 13: The Top Tips You need to Learn about Data in your Mobile App

UNDERSTAND WEB SERVICESThe Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 14: The Top Tips You need to Learn about Data in your Mobile App

Types of Web Services

01 02

0403

Simple Object Access protocol (SOAP)

Representational State Transfer (REST)

Remote Procedure Call (RPC)

Calls over HTTP

The Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 15: The Top Tips You need to Learn about Data in your Mobile App

EVOLUTION OF WEB SERVICES?The Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 16: The Top Tips You need to Learn about Data in your Mobile App

UNDERSTAND RESTThe Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 17: The Top Tips You need to Learn about Data in your Mobile App
Page 18: The Top Tips You need to Learn about Data in your Mobile App

WHAT IS REST?

RESOURCES

VERBS

URL

The Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 19: The Top Tips You need to Learn about Data in your Mobile App

WHAT SHOULD YOU KNOW ABOUT REST?

Resources REST uses addressable resources to define the structure of the API. These are the URLs you use to get to pages on the web

Request HeadersThese are additional instructions that are sent with the request. These might define what type of response is required or authorization details.

Request VerbsThese describe what you want to do with the resource. A browser typically issues a GET verb to instruct the endpoint it wants to get data, however there are many other verbs available including things like POST, PUT and DELETE.

Request Body

Data that is sent with the request. For example a POST (creation of a new

item) will required some data which is typically sent as the request body in

the format of JSON or XML.

Response Body

This is the main body of the response. If the request was to a web server, this

might be a full HTML page, if it was to an API, this might be a JSON or XML

document.

Response Status codes

These codes are issues with the response and give the client details on

the status of the request.

The Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 20: The Top Tips You need to Learn about Data in your Mobile App

REST & HTTP VERBS

GETRequests a representation of the specified resource. Requests using GET should only

retrieve data and should have no other effect.

POSTRequests that the server accept the entity enclosed in the request as a new subordinate of the web resource identified by the URI.

PUTRequests that the enclosed entity be

stored under the supplied URI.

DELETEDeletes the specified resource.

The Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 21: The Top Tips You need to Learn about Data in your Mobile App

EXAMPLES OF REST

/Products

RESOURCE

EXPECTED OUTCOME

VERB

RESPONSE CODE

/Products?Color=green/Products

/Products/81

/Products/881

/Products/81

/Products/81

GET

GET

POST

GET

GET

PUT

DELETE

A list of all products in the systemA list of all products in the system where the color is redCreation of a new productProduct with an ID of 81Some error message

Update of the product with ID of 81Deletion of the product with ID of 81

200/OK

200/OK

201/Created

200/OK

404/Not Found

204/No Content

204/No Content

The Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 22: The Top Tips You need to Learn about Data in your Mobile App

SWAGGER UIThe Top Reasons You Need to Learn about Data in Your Windows Phone App

BENEFITS

GENERATE CLIENT CODE BASED ON YOUR SWAGGER

KEEPS YOUR API FULLY DOCUMENTED

UNDERSTAND REST API QUICKLY

UPDATED WHEN YOU BUILD YOUR API

Page 23: The Top Tips You need to Learn about Data in your Mobile App
Page 24: The Top Tips You need to Learn about Data in your Mobile App
Page 25: The Top Tips You need to Learn about Data in your Mobile App

Testing REST Web ServicesThe Top Reasons You Need to Learn about Data in Your Windows Phone App

BROWSERDEVELOPER EXTENSIONS

Web-based REST/Web Services Clients

FIDDLERFree web debugging tool

which logs all HTTP(S) traffic between your computer and

the Internet.

LINQPADInteractively query SQL

databases (among other data sources such as OData or WCF Data Services) using LINQ, as well as interactively writing

C# code without the need for an IDE.

SoapUISoapUI is an open-source web service testing application for service-oriented architectures

(SOA) and representational state transfers (REST). Its functionality covers web

service inspection, invoking, development, simulation and mocking, functional testing, load and compliance testing.

Page 26: The Top Tips You need to Learn about Data in your Mobile App

DEMO

The Top Reasons You Need to Learn about Data in Your Windows Phone App

http://baseball-stats.info/api/Teams

Page 27: The Top Tips You need to Learn about Data in your Mobile App

KNOW HOW TO CACHE DATAIN THE APPThe Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 28: The Top Tips You need to Learn about Data in your Mobile App

01

02

04

03

LOCALData that exists on the current device and is backed up in the cloud.

APP DATA STORAGEThe Top Reasons You Need to Learn about Data in Your Windows Phone App

LOCALCACHEPersistent data that exists only on the current device.

ROAMINGData that exists on all devices on

which the user has installed the app.

TEMPORARYData that could be removed by the

system at any time.

Page 29: The Top Tips You need to Learn about Data in your Mobile App

DATA TYPES FOR CACHING

UInt8, Int16, UInt16, Int32, UInt32, Int64,

UInt64, Single, Double Boolean

Char16, String DateTime, TimeSpan

GUID, Point, Size, Rect ApplicationDataCompositeValue

The Top Reasons You Need to Learn about Data in Your Windows Phone App

Note that there is no binary type. If you need to store binary data, use an app file

Page 30: The Top Tips You need to Learn about Data in your Mobile App

EXAMPLES OF DATA CACHING

LOCALSETTINGS

The Top Reasons You Need to Learn about Data in Your Windows Phone App

Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;localSettings.Values["exampleSetting"] = "Hello Windows";

Windows.Storage.ApplicationDataCompositeValue composite = new Windows.Storage.ApplicationDataCompositeValue();composite["intVal"] = 1;composite["strVal"] = "string";

localSettings.Values["exampleCompositeSetting"] = composite;Object value = localSettings.Values["exampleSetting"];

Windows.Storage.ApplicationDataCompositeValue composite = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["exampleCompositeSetting"];

localSettings.Values.Remove("exampleSetting");

Page 31: The Top Tips You need to Learn about Data in your Mobile App

EXAMPLES OF DATA CACHING

LOCALFOLDER

The Top Reasons You Need to Learn about Data in Your Windows Phone App

Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;

Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatter = new Windows.Globalization.DatetimeFormatting.DateTimeFormatter("longtime");

StorageFile sampleFile = await localFolder.CreateFileAsync("dataFile.txt", CreateCollisionOption.ReplaceExisting);await FileIO.WriteTextAsync(sampleFile, formatter.Format(DateTime.Now));

StorageFile sampleFile = await localFolder.GetFileAsync("dataFile.txt");String timestamp = await FileIO.ReadTextAsync(sampleFile);

Page 32: The Top Tips You need to Learn about Data in your Mobile App

EXAMPLES OF DATA CACHINGThe Top Reasons You Need to Learn about Data in Your Windows Phone App

TEMPORARYFOLDER

Windows.Storage.StorageFolder temporaryFolder = Windows.Storage.ApplicationData.Current.TemporaryFolder;Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatter = new Windows.Globalization.DatetimeFormatting.DateTimeFormatter("longtime");

StorageFile sampleFile = await temporaryFolder.CreateFileAsync("dataFile.txt", CreateCollisionOption.ReplaceExisting);await FileIO.WriteTextAsync(sampleFile, formatter.Format(DateTime.Now));

StorageFile sampleFile = await temporaryFolder.GetFileAsync("dataFile.txt");String timestamp = await FileIO.ReadTextAsync(sampleFile);

Page 33: The Top Tips You need to Learn about Data in your Mobile App

EXAMPLES OF DATA CACHINGThe Top Reasons You Need to Learn about Data in Your Windows Phone App

void InitHandlers(){ Windows.Storage.ApplicationData.Current.DataChanged += new TypedEventHandler<ApplicationData, object>(DataChangeHandler);}

void DataChangeHandler(Windows.Storage.ApplicationData appData, object o){ // Refresh your data}

ROAMINGFOLDER

Page 34: The Top Tips You need to Learn about Data in your Mobile App

SQL AND NOSQL DATA SOLUTIONS

SQLiteA relational database management system contained in a C programming library. In contrast to other database management systems, SQLite is not implemented as a separate process that a client program running in another process accesses. Rather, it is part of the using program.

The Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 35: The Top Tips You need to Learn about Data in your Mobile App

PICK AND USE A GOOD MVVMFRAMEWORKThe Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 36: The Top Tips You need to Learn about Data in your Mobile App

BEAUTY OF MVVMThe Top Reasons You Need to Learn about Data in Your Windows Phone App

MODEL

VIEW

VIEW MODEL

Page 37: The Top Tips You need to Learn about Data in your Mobile App

DEMO

The Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 38: The Top Tips You need to Learn about Data in your Mobile App

LEARN GREAT UX AND HOW TO SHOW DATA IN YOUR APPThe Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 39: The Top Tips You need to Learn about Data in your Mobile App

EXAMPLES OF DATA VIZThe Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 40: The Top Tips You need to Learn about Data in your Mobile App

BOOKS ABOUT DATA VIZThe Top Reasons You Need to Learn about Data in Your Windows Phone App

Page 41: The Top Tips You need to Learn about Data in your Mobile App

FINALLY!!

Page 42: The Top Tips You need to Learn about Data in your Mobile App
Page 43: The Top Tips You need to Learn about Data in your Mobile App

CHRIS WOODRUFF

SKYPECWOODRUFF

TWITTERCWOODRUFF

WEBSITECHRISWOODRUFF.COM

[email protected]

PHONE616.724.6885

LINKEDINCHRIS.WOODRUFF

THANK YOU