Upload
daniel-meixner
View
574
Download
4
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
Windows und Windows Phone App Entwicklung
Daniel MeixnerTechnical EvangelistMicrosoft Deutschland@DanielMeixner
DevelopersDevelopersDevelopersDevelopers.Net
Agenda
Platform Convergence
Windows Universal Apps
Further code sharing strategies
People work across phones, tablets, and PCs
Programming skills
Development tools
Languages, frameworks
Components
Runtimes
Platform convergence is a jouney.
unified experiencemultiple devicesminimum work
Introducing universal Windows apps
Streamlined end-to-end development
User Interface App Model Tools StoreAPIs
You can adapt one design across devices
User Interface App Model Tools StoreAPIs
You can tailor the design to each device
User Interface App Model Tools StoreAPIs
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
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
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
Tools
Write and debug your code with ease
User Interface App Model StoreAPIs
You can let customers buy once, use anywhere
Store
Made for Windows Phones and Windows PCs
User Interface App Model ToolsAPIs
18
| |
Legend
Overall Strategy
Embrace & separate
differences
Separate View
(MVVM)
Separate
platform
specific calls
(Libs)
Try to share everything
else
Let‘s see...
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
Portable Class Library
Windows Phone
Silverlight
.NET Framework 4.5
.NET for Windows
Store Apps
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
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}
}
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
}}
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}
}
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}
}
Dirty Tricks Vol.1: Delegates
Dirty Tricks Vol.2: Up-Casting & Down-Casting to object
Not so dirty Trick: Extension Methods
Windows 8:
HttpWebResponse.GetResponseAsync()
Windows Phone 8:
HttpWebResponse.GetResponseAsync()
Demo
Share what you can share.Don‘t share what you can‘t share.
What do you want to share today?
Microsoft Azure
Store Registration, PurchasingPush Notifications …
Universal App Sync
Universal App
Visual Studio
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!
Daniel MeixnerTechnical EvangelistMicrosoft Deutschland@DanielMeixner
DevelopersDevelopersDevelopersDevelopers.Net
Q&A