30
Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Embed Size (px)

Citation preview

Page 1: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Build Smart: Developing for Windows Phone and Windows 8Vaughan KnightNokia

WPH323

Page 2: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

@vaughanknight #auteched #WPH323

Page 3: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Quick OverviewWhat We’ll Cover

The challengeThe platforms6 approaches

#ifInheritancePartialPortableWinRT

Page 4: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

The ChallengeNo problem

Two platformsWindows Phone 7.5Windows 8

Similar toolsVS2010 ExpressVS2012

Similar technology stackC#XAML

Page 5: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

The ChallengeNo problem

Similar != SameSame, but different

.NET VersionPackage name clashesNew approaches

async await

Page 6: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

A great place to start

Setting Up The Projects

Page 7: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Setting Up The ProjectsA great place to start

Windows Phone ApplicationWindows 8 ApplicationCommon Code

Page 8: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

What? #if

Page 9: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

#ifFirst steps

Visualise your codeDon’t rewrite your original applicationNon functional compilationLearn the discrepanciesAbstract differencesFlesh out the missing codeVoila!

Page 10: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

#ifFirst steps

But it gets messyHard to keep track of codeSource control nightmare

#if is effectively conditional block commenting

Page 11: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

SomeMethod(){

DoThis();DoSomethingElse();

}

The problem with block commenting

Page 12: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

SomeMethod(){

#if WINDOWS_PHONENewXPlatformMethodWrappingDoSomething();

#elseDoThis();

#endif}

The problem with block commenting

Page 13: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Abstract Inheritance

Page 14: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Abstract InheritanceGlass Half Full

Abstraction of codeMinimalises conditional code

Still has conditional codeFactory pattern can reduce this further

Page 15: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

SomeMethod(){

AwesomeClassAbstract foo;#if WINDOWS_PHONE

foo = new WindowsPhoneAwesomeClass();#else

foo = new WindowsAwesomeClass();#endif

}

Using factories

Page 16: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

SomeMethod(){

AwesomeClassAbstract foo = factory.CreateAwesome();}AppInit(){

#if WINDOWS_PHONEfactory = new WindowsPhoneFactory();

#elsefactory = new WindowsFactory();

#endif}

Using factories

Page 17: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Partial

Page 18: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

PartialTwo Half Full Glasses

Abstracted code for platformsNo factories for platform specificsCleanReadableSimple

Cross platform usage may not be evident

Page 19: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Portable Libraries

Page 20: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Portable LibrariesA Glass For Everyone

Write onceUse everywhereOne projectOne set of codeFastest

Page 21: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Portable LibrariesA Glass For Everyone

No targeting for dependenciesAll dependencies need to be portable librariesConstrains capabilityConstrains thinking

Page 22: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

WinRT Libraries

Page 23: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

WinRT LibrariesA Glass for All Languages

JavaScriptC#C++One set of codeOne project

Page 24: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

WinRT LibrariesA Glass for All Languages

Not for Windows Phone 7Should only be used when cross language is requiredNot ideal for legacy codeLook before you leap

Page 25: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Demo

With highest common returns

Lowest Common Denominator

Page 26: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Lowest Common DenominatorHighest Common Returns

One code baseOne set of filesSupport for platform dependenciesRequires foresightFast portingCan adapt to any other approach

Page 27: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Lowest Common DenominatorHighest Common Returns

Constrains thinkingNot the best way to learnCross checking between projects

Page 28: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Windows Phone and Windows 8Where to Start?

Windows Phone to Windows 8Windows 8 to Windows Phone

Create a tablet and desktop experience on Windows 8Create companion and portable experiences on Windows Phone

Publish it to the marketplace and store!

Page 29: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

Related Content

WPH333 -

Hands-on Labs (session codes and titles)

Product Demo Stations (demo station title and location)

Related Certification Exam

DEV334 - Windows 8 Games and High Performance DevelopmentNokia Stand

Page 30: Build Smart: Developing for Windows Phone and Windows 8 Vaughan Knight Nokia WPH323

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to

be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS

PRESENTATION.