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

Preview:

Citation preview

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

WPH323

@vaughanknight #auteched #WPH323

Quick OverviewWhat We’ll Cover

The challengeThe platforms6 approaches

#ifInheritancePartialPortableWinRT

The ChallengeNo problem

Two platformsWindows Phone 7.5Windows 8

Similar toolsVS2010 ExpressVS2012

Similar technology stackC#XAML

The ChallengeNo problem

Similar != SameSame, but different

.NET VersionPackage name clashesNew approaches

async await

A great place to start

Setting Up The Projects

Setting Up The ProjectsA great place to start

Windows Phone ApplicationWindows 8 ApplicationCommon Code

What? #if

#ifFirst steps

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

#ifFirst steps

But it gets messyHard to keep track of codeSource control nightmare

#if is effectively conditional block commenting

SomeMethod(){

DoThis();DoSomethingElse();

}

The problem with block commenting

SomeMethod(){

#if WINDOWS_PHONENewXPlatformMethodWrappingDoSomething();

#elseDoThis();

#endif}

The problem with block commenting

Abstract Inheritance

Abstract InheritanceGlass Half Full

Abstraction of codeMinimalises conditional code

Still has conditional codeFactory pattern can reduce this further

SomeMethod(){

AwesomeClassAbstract foo;#if WINDOWS_PHONE

foo = new WindowsPhoneAwesomeClass();#else

foo = new WindowsAwesomeClass();#endif

}

Using factories

SomeMethod(){

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

#if WINDOWS_PHONEfactory = new WindowsPhoneFactory();

#elsefactory = new WindowsFactory();

#endif}

Using factories

Partial

PartialTwo Half Full Glasses

Abstracted code for platformsNo factories for platform specificsCleanReadableSimple

Cross platform usage may not be evident

Portable Libraries

Portable LibrariesA Glass For Everyone

Write onceUse everywhereOne projectOne set of codeFastest

Portable LibrariesA Glass For Everyone

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

WinRT Libraries

WinRT LibrariesA Glass for All Languages

JavaScriptC#C++One set of codeOne project

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

Demo

With highest common returns

Lowest Common Denominator

Lowest Common DenominatorHighest Common Returns

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

Lowest Common DenominatorHighest Common Returns

Constrains thinkingNot the best way to learnCross checking between projects

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!

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

© 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.

Recommended