Get a flying start with Windows Phone 7 - NDC2010

53
GET A FLYING START WITH WP7 JONAS FOLLESØ [email protected] http://jonas.follesoe.no @follesoe

description

Windows Phone 7 is brand new, totally fresh operating system that will appear in phones before Christmas. The new platform is a complete rewrite and offers lots of interesting opportunities to third party developers. The development platform for Windows Phone 7 is all based around managed code and the tools and frameworks you already know and love. This presentation you will give you an overview of the Windows Phone 7 development platform, and how you can leverage your existing Silverlight skills to build great applications for the Windows Phone 7 marketplace.The session assumes some prior knowledge of Silverlight, as the focus of this presentation will be features that are specific to the phone. It will not only cover the basics of the Windows Phone 7 platform, but also how you can re–use many of the same patterns, frameworks, techniques and practices that you use when building regular Silverlight applications.

Transcript of Get a flying start with Windows Phone 7 - NDC2010

Page 1: Get a flying start with Windows Phone 7 - NDC2010

GET A FLYING START WITH WP7

JONAS FOLLESØ[email protected]

http://jonas.follesoe.no@follesoe

Page 2: Get a flying start with Windows Phone 7 - NDC2010

ABOUT ME

JONAS FOLLESØ[email protected]

http://jonas.follesoe.no@follesoe

Page 3: Get a flying start with Windows Phone 7 - NDC2010

AGENDA:- TDD- RX & ASYNC- MVVM & IOC- BLEND 4- LOCATION- NOTIFICATION

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/2

07

92

78

7@

N0

0/2

24

86

23

39

1/

Page 4: Get a flying start with Windows Phone 7 - NDC2010

KNOW SILVERLIGHT?

THEN YOU KNOW WP7!

Page 5: Get a flying start with Windows Phone 7 - NDC2010

FLIGHTS NORWAY

MONITORARRIVALS AND

DEPARTURES

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/sv

en

werk

/2

18

18

49

28

0/

Page 6: Get a flying start with Windows Phone 7 - NDC2010

FLIGHTS NORWAY

WHAT WE ARE GOING TO

BUILD

Page 7: Get a flying start with Windows Phone 7 - NDC2010

TDD

FUNDAMENTALPRACTICE

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/m

ad

_hou

se_p

hoto

gra

ph

y/

44

40

87

13

80

/

Page 8: Get a flying start with Windows Phone 7 - NDC2010

WP7SILVERLIGHT 3

.NET 4.0

3 RUNTIMESMAKES

THINGS HARD

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/ta

mb

ako

/39

74

80

93

61

/

Page 9: Get a flying start with Windows Phone 7 - NDC2010

• Unit Testing and TDD is a waste of time

• Silverlight Unit Test Framework from

Microsoft

• Silverlight Port of NUnit

• Assembly Sharing

• Other

Page 10: Get a flying start with Windows Phone 7 - NDC2010

9

13

5

12

Sales

Waste of Time

SLUT

Nunit

Other

Assembly Shar-ing

Page 11: Get a flying start with Windows Phone 7 - NDC2010

TDD IS ALL ABOUT

FLOW

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/ze

non

line/3

43

13

65

55

6/

Page 12: Get a flying start with Windows Phone 7 - NDC2010

FASTER FEEDBACK CYCLE FOR

SILVERLIGHT TDD

Page 13: Get a flying start with Windows Phone 7 - NDC2010

TDDDEMO

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/in

fom

ofo

/14

05

30

34

78

/

Page 14: Get a flying start with Windows Phone 7 - NDC2010

RESTSERVICES

WITH FLIGHT INFORMATION

http://flydata.avinor.no/http://open.bekk.no/2009/12/13/hva-skjer-nar-man-gir-bort-flydata-gratis/

Page 15: Get a flying start with Windows Phone 7 - NDC2010

http://flydata.avinor.no/XmlFeed.asp?airport=OSL<?xml version="1.0" encoding="iso-8859-1"?><airport name="OSL"> <flights lastUpdate="2010-06-14T06:29:12"> <flight uniqueID="1054121"> <airline>DY</airline> <flight_id>DY422</flight_id> <dom_int>D</dom_int> <schedule_time>2010-06-12T08:55:00</schedule_time> <arr_dep>D</arr_dep> <airport>MOL</airport> </flight> </flights></airport>

Page 16: Get a flying start with Windows Phone 7 - NDC2010

http://flydata.avinor.no/airlineNames.asp

<?xml version="1.0" encoding="iso-8859-1"?><airlineNames> <airlineName code="AA" name="American Airlines"/> <airlineName code="AAF" name="Aigle Azur"/> <airlineName code="AAG" name="Atlantic Airlines"/> <airlineName code="AAT" name="Austrian Airtransport"/> <!-- ... --></airlineNames>

Page 17: Get a flying start with Windows Phone 7 - NDC2010

http://flydata.avinor.no/airportNames.asp

<?xml version="1.0" encoding="iso-8859-1"?><airportNames> <airportName code="OSD" name="Østersund"/> <airportName code="OSH" name="Oshkosh"/> <airportName code="OSI" name="Osijek"/> <airportName code="OSK" name="Oskarshamn"/> <airportName code="OSL" name="Oslo"/> <!-- ... --></airportNames>

Page 18: Get a flying start with Windows Phone 7 - NDC2010

http://flydata.avinor.no/flightStatuses.asp

<?xml version="1.0" encoding="iso-8859-1"?><flightStatuses> <flightStatus code="N" statusTextEn="New info" /> <flightStatus code="E" statusTextEn="New time" /> <flightStatus code="D" statusTextEn="Departed" /> <flightStatus code="A" statusTextEn="Arrived" /> <flightStatus code="C" statusTextEn="Cancelled" /></flightStatuses>

Page 19: Get a flying start with Windows Phone 7 - NDC2010

ALL NETWORKING

IN SILVERLIGHT IS

ASYNCHRONOUS

Page 20: Get a flying start with Windows Phone 7 - NDC2010

RX

MAKING ASYNC

PROGRAMMING

LESS DIFFICULT

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/ad

ew

ale

_osh

ineye/3

59

01

40

05

1/

Page 21: Get a flying start with Windows Phone 7 - NDC2010

COMPOSING ASYNCHRONOU

S AND EVENT-BASED

PROGRAMS USING

OBSERVABLE COLLECTIONS

Page 22: Get a flying start with Windows Phone 7 - NDC2010

var move = Observable.FromEvent(LayoutRoot, "MouseMove");var down = Observable.FromEvent(LayoutRoot, "MouseLeftButtonDown");var up = Observable.FromEvent(LayoutRoot, "MouseLeftButtonUp");

IObservable<Point> whereUserIsDragging = move.SkipUntil(down) .TakeUntil(up) .Repeat() .Select(e => e.EventArgs.GetPosition(LayoutRoot));

whereUserIsDragging.Subscribe(p => Paint(p.X, p.Y));

Page 23: Get a flying start with Windows Phone 7 - NDC2010

RX DEMO

Page 24: Get a flying start with Windows Phone 7 - NDC2010

MVVM

PATTERN FOR BINDABLE UI

Page 25: Get a flying start with Windows Phone 7 - NDC2010

Data Model

VIEW

XAML

Code-BehindEvent

Handlers

APP LOGIC IN CODE BEHIND IS HARD TO TEST

AND MAINTAIN

Page 26: Get a flying start with Windows Phone 7 - NDC2010

Data Model

VIEW

XAML

Code-Behind

VIEW MODEL

State + Operations

Change notification

Data-binding and commands

SEPARATE USINGMVVM

Page 27: Get a flying start with Windows Phone 7 - NDC2010

COMMUNICATION

App Service

View Model

App Service View Model

View Model

View Model

View Model View Model

Page 28: Get a flying start with Windows Phone 7 - NDC2010

EVENT AGGREGATOR

App Service

App Service

View Model View Model

View Model

View Model

View Model View Model

Event Aggregator

Page 29: Get a flying start with Windows Phone 7 - NDC2010

Message

VIEW MODEL COMMUNICATION

Data Model

View

XAML

Code-Behin

d

Data Model

View

XAML

Code-Behind

Message

View Model

State + Operations

View Model

State + Operations

View

XAML

Code-Behind

View Model

State + Operations

Publish messages

Subscribe to messages

Event Aggregator

Page 30: Get a flying start with Windows Phone 7 - NDC2010

MVVM SHOULD BE LIGHT WEIGHT

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/tr

eeh

ou

se1

97

7/2

89

24

17

80

5/

Page 31: Get a flying start with Windows Phone 7 - NDC2010

http://mvvmlight.codeplex.com/

Page 32: Get a flying start with Windows Phone 7 - NDC2010

MVVM DEMO

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/2

07

92

78

7@

N0

0/2

24

86

23

39

1/

Page 33: Get a flying start with Windows Phone 7 - NDC2010

DI

KEEP THINGS SEPARATE

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/om

arr

un

/46

72

53

12

53

/in

/ph

oto

stre

am

More in-depth information:The Dependency Inversion Principle Applied

Fredrik Kalseth, Friday 10:20

Page 34: Get a flying start with Windows Phone 7 - NDC2010

DI LETS YOU INJECT

EXTERNALDEPENDENCIE

S

Page 35: Get a flying start with Windows Phone 7 - NDC2010

IMPORTANT TECHNIQUE ON WP7 TO

SIMULATE SENSORS

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/h

ow

zey/2

88

04

55

76

2/

Page 36: Get a flying start with Windows Phone 7 - NDC2010
Page 37: Get a flying start with Windows Phone 7 - NDC2010

ISOLATED STORAGE

FOR SIMPLE DATA STORAGE

Page 38: Get a flying start with Windows Phone 7 - NDC2010

NOSQLFOR WP7?

Page 39: Get a flying start with Windows Phone 7 - NDC2010

DI &ISOLATED STORAGE

DEMO

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/om

arr

un

/46

72

53

12

53

/in

/ph

oto

stre

am

Page 40: Get a flying start with Windows Phone 7 - NDC2010

METRO DESIGN

LANGUAGE

Page 41: Get a flying start with Windows Phone 7 - NDC2010

PIVOT CONTROL

Page 42: Get a flying start with Windows Phone 7 - NDC2010

HUB CONTROL

Page 43: Get a flying start with Windows Phone 7 - NDC2010

BLEND 4DEMO

Page 44: Get a flying start with Windows Phone 7 - NDC2010

LOCATION AWARENESSIS KEY WHEN

ON THE GO

Page 45: Get a flying start with Windows Phone 7 - NDC2010

SAME API IN .NET 4 &

WP7

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/p

hoto

gra

ham

/19

83

24

03

1/

Page 46: Get a flying start with Windows Phone 7 - NDC2010

LOCATION AWARENESS

DEMO

Page 47: Get a flying start with Windows Phone 7 - NDC2010

PUSH NOTIFICATIONS

KEEP YOU INFORMED

Page 48: Get a flying start with Windows Phone 7 - NDC2010

WP7 PUSH NOTIFICATIONS

Microsoft Push

Notification

Services

Your Web Applicatio

n

PUSH CLIENT

Notification Namespaces

Push Library

Your WP Application

1Open Channel

2 Hand off channel

URL

3 Pushmessage

4Push message

Page 49: Get a flying start with Windows Phone 7 - NDC2010

PUSH NOTIFICATION

S DEMO

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/ko

zlosk

i/2

30

65

10

52

0/

Page 50: Get a flying start with Windows Phone 7 - NDC2010

SUMMARY:- TDD- RX & ASYNC- MVVM & IOC- BLEND 4- LOCATION- NOTIFICATION

htt

p:/

/ww

w.fl

ickr

.com

/ph

oto

s/2

07

92

78

7@

N0

0/2

24

86

23

39

1/

Page 51: Get a flying start with Windows Phone 7 - NDC2010

FORK ME ON GITHUB

http://github.com/follesoe/FlightsNorway

Page 52: Get a flying start with Windows Phone 7 - NDC2010

THANKS!

JONAS FOLLESØ[email protected]

http://jonas.follesoe.no@follesoe

Page 53: Get a flying start with Windows Phone 7 - NDC2010