36
Windows und Windows Phone App Entwicklung Daniel Meixner Technical Evangelist Microsoft Deutschland @DanielMeixner DevelopersDevelopersDevelopersDevelopers.Net

Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Embed Size (px)

DESCRIPTION

Mit dem Release von Windows Phone 8 und Windows 8 setzen die beiden Betriebssysteme zum ersten Mal auf den gleichen Kernel auf. Für Entwickler stellt sich hier natürlich die Frage: Wie einfach ist es mit einmaligem Programmieraufwand beide Plattformen zu bedienen? Dieses Session stellt Euch Strategien vor, die Ihr nutzen könnt um Eure Arbeit nicht zweimal machen zu müssen und arbeitet die Stellen heraus, an denen es sinnvoll ist, dennoch zweimal den Code anzufassen.

Citation preview

Page 1: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Windows und Windows Phone App Entwicklung

Daniel MeixnerTechnical EvangelistMicrosoft Deutschland@DanielMeixner

DevelopersDevelopersDevelopersDevelopers.Net

Page 2: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Agenda

Platform Convergence

Windows Universal Apps

Further code sharing strategies

Page 3: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)
Page 4: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

People work across phones, tablets, and PCs

Page 5: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Programming skills

Development tools

Languages, frameworks

Components

Runtimes

Page 6: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Platform convergence is a jouney.

Page 7: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)
Page 8: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

unified experiencemultiple devicesminimum work

Page 9: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Introducing universal Windows apps

Page 10: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Streamlined end-to-end development

User Interface App Model Tools StoreAPIs

Page 11: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

You can adapt one design across devices

User Interface App Model Tools StoreAPIs

Page 12: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

You can tailor the design to each device

User Interface App Model Tools StoreAPIs

Page 13: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

13

80% exact same XAML 20% custom

Common SignatureOptimized

DatePicker

TimePicker

CommandBar

AppBar

Button

CheckBox

RadioButton ProgressBar

Slider

ToggleSwitchHub

Pivot

ListView

GridView

User Interface App Model Tools StoreAPIs

Page 14: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

App Model APIs

Develop your app in a way that’s familiar

User Interface Tools Store

HTML / CSS

JavaScript

Windows Runtime

C# / VB

Windows Kernel Services

C / C++

XAML DirectX

Page 15: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

15

The Windows Runtime (WinRT) is the shared runtime and API space used by store apps across the Windows platform (phone and client)

Dramatic convergence in 8.1• Goal is 100% convergence for dev scenarios

• In 8.0, we had ~30% API convergence

• With 8.1, we move well past 90%+ convergence

App Model APIsUser Interface Tools Store

Page 16: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Tools

Write and debug your code with ease

User Interface App Model StoreAPIs

Page 17: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

You can let customers buy once, use anywhere

Store

Made for Windows Phones and Windows PCs

User Interface App Model ToolsAPIs

Page 18: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

18

| |

Legend

Page 19: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)
Page 20: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)
Page 21: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Overall Strategy

Embrace & separate

differences

Separate View

(MVVM)

Separate

platform

specific calls

(Libs)

Try to share everything

else

Let‘s see...

Page 22: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Reuse: Portable Class Library

Reusing pre-built components or libraries

7/16/2014Microsoft

confidential

2

2

• Portable Class Library

• Managed Code

• Reusable library

• New:

• Supports XAML

• Supports Windows.* Namespace

Page 23: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Portable Class Library

Windows Phone

Silverlight

.NET Framework 4.5

.NET for Windows

Store Apps

Page 24: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Shared Code: File-Level (Add as Link)

• App logic common to both apps, but not portable

• Code containing Windows Runtime API calls

• Share outside of Universal Apps

Page 25: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Shared Code: Classpart-Level (Partial Classes)

public partial class MyClass{

public void CommonMethodA(){

// code that is common}

public int CommonMethodB(){

int result = 0;// code that is commonreturn result;

}

}

public partial class MyClass{

public void PlatformSpecificMethod(){

// specific code for platform Á}

}}

public partial class MyClass{

public void PlatformSpecificMethod(){

// specific code for platform B}

}

Page 26: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Shared Code: Line Level (Conditional Compilation)

public class MyClass{

public void CommonMethodA(){

// code that is common to Windows Phone 8 and Windows 8}

public int CommonMethodB(){

int result = 0;// code that is common to Windows Phone 8 and Windows 8return result;

}

public void PlatformSpecificMethod(){

#if WINDOWS_APP// code for W8.1#else// …#endif

}}

Page 27: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

public class MyWin8Class : MyBaseClass{

public override void PlatformSpecificMethod(){// Implement this method specific to Win 8

} } }

Patterns: Abstract Base Class

public abstract class MyBaseClass{

public void CommonMethodA(){

// code that is common}

public int CommonMethodB(){

int result = 0;

// code that is commonreturn result;

}

public abstract void PlatformSpecificMethod();}

Add as Link / Shared Folder

Portable Class Library

public class MyWP8Class : MyBaseClass{

public override void PlatformSpecificMethod(){// Implement this method specific to WP8}

}

Page 28: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

public class MyClass{

private IPlatformSpecificCode _platformImpl;

public MyClass(IPlatformSpecificCode platformImpl){

_platformImpl = platformImpl;}

public void CommonMethodA(){ ... }

public int CommonMethodB(){ ... }

public void PlatformSpecificMethod(){

_platformImpl.PlatformSpecificMethodImpl();}

}

public interface IPlatformSpecificCode{

void PlatformSpecificMethodImpl();}

// Windows 8 app projectpublic class MyWin8Implementation : IPlatformSpecificCode

{public void PlatformSpecificMethod(){

// Implemented for Windows 8}

}

Patterns: Interfaces & DI

// Windows Phone app projectpublic class MyWinPhone 8Implementation : IPlatformSpecificCode

{public void PlatformSpecificMethod(){

// Implemented for Windows Phone 8}

}

Page 29: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Dirty Tricks Vol.1: Delegates

Page 30: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Dirty Tricks Vol.2: Up-Casting & Down-Casting to object

Page 31: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Not so dirty Trick: Extension Methods

Windows 8:

HttpWebResponse.GetResponseAsync()

Windows Phone 8:

HttpWebResponse.GetResponseAsync()

Page 32: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Demo

Page 33: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Share what you can share.Don‘t share what you can‘t share.

Page 34: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

What do you want to share today?

Microsoft Azure

Store Registration, PurchasingPush Notifications …

Universal App Sync

Universal App

Visual Studio

Page 35: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Summary

Building for both WP8.1 & WP8.1 is easy

Universal Apps are flexible

Alernative ways to share code exist

More to come … stay tuned!

Page 36: Windows und Windows Phone App Entwicklung (Daniel Meixner, DWX 2014)

Daniel MeixnerTechnical EvangelistMicrosoft Deutschland@DanielMeixner

DevelopersDevelopersDevelopersDevelopers.Net

Q&A