Architecting applications for Windows 8 and Windows Phone 8 by Karl Ots / @fincooper

1,855 views
1,746 views

Published on

WinRT and WinPRT share the same core, so it makes a lot of sense to optimize your applications for maximum codeshare. I give an overview of the key similarities and differences of the platforms. I share best practices of some common application scenarios.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,855
On SlideShare
0
From Embeds
0
Number of Embeds
957
Actions
Shares
0
Downloads
22
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Architecting applications for Windows 8 and Windows Phone 8 by Karl Ots / @fincooper

  1. 1. Architecting applicationsfor WinRT and WinPRT
  2. 2. About the the presenter • Karl Ots, Technical Consultant at Symbio • Windows Phone 8 and Windows 8 trainer • Windows Azure Insider • Co-founder of Young Developers Finland • Microsoft Student Partner#td2013fi @fincooper
  3. 3. What we’ll cover • What shared core means and what it doesn’t • UX differences • Porting vs maximum reuse • Best practices of common scenarios • Demos#td2013fi @fincooper
  4. 4. Shared core
  5. 5. Shared WinRT Core Networking Proximity Sensors Location File System Core app model Threading#td2013fi @fincooper
  6. 6. Windows 8 Platform#td2013fi @fincooper
  7. 7. Some definitions • CLR – common language runtime • BCL – base class library • FCL – framework class library#td2013fi @fincooper
  8. 8. Windows 8 app model#td2013fi @fincooper
  9. 9. WP8 MANAGED app model#td2013fi @fincooper
  10. 10. WP8 app model Native app model Legacy app model#td2013fi @fincooper
  11. 11. Windows Phone Runtime •Phone-specific additions to Windows Runtime include • Speech synthesis and recognition • Windows.Phone.PersonalInformation • LockScreen and LockScreenManager • More… Full WinRT (around 11,000 members) Subset adopted for New for Windows Windows Phone Phone Runtime Runtime (around (around 600 2,800 members) members)#td2013fi @fincooper
  12. 12. Targeting maximum reuse
  13. 13. Strategies for targeting both platforms• Use Model-View-ViewModel• Share portable .NET code in Portable Class Library• Use common Windows Runtime API (Add as Link)• Use Windows Runtime Components for language interoperability• Use #if conditionals for small code differences• Use extension methods to bridge implementation differences#td2013fi @fincooper
  14. 14. Cross-platform app architecture with PLC#td2013fi @fincooper
  15. 15. Régis LaurentDEMO Director of Operations, Global Knowledge Competencies include:PixPresenter Gold Learning Silver System Management
  16. 16. What’s portable in PixPresenter? Platform-specific Portable /shareable Platform-specific Windows Phone app Windows Store app#td2013fi @fincooper
  17. 17. “Add as Link”#td2013fi @fincooper
  18. 18. Régis LaurentDEMO Director of Operations, Global Knowledge Competencies include:Add as Link Gold Learning Silver System Management
  19. 19. Small code differences Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { double _accelX = args.Reading.AccelerationX; double _accelY = args.Reading.AccelerationY; // Update ellipse location }); Deployment.Current.Dispatcher.BeginInvoke(() => { double _accelX = args.Reading.AccelerationX; double _accelY = args.Reading.AccelerationY; //Update ellipse location });#td2013fi @fincooper
  20. 20. #if conditional blocks Threading #if NETFX_CORE Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { #else Deployment.Current.Dispatcher.BeginInvoke(() => { #endif double _accelX = args.Reading.AccelerationX; double _accelY = args.Reading.AccelerationY;#td2013fi @fincooper
  21. 21. HttpWebResponse and HttpWebRequest var request = (HttpWebRequest)WebRequest.Create(autoCompleteUri); HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync(); // retrieve data using StreamReader#td2013fi @fincooper
  22. 22. HttpWebResponse and HttpWebRequest var request = (HttpWebRequest)WebRequest.Create(autoCompleteUri); request.BeginGetResponse(new AsyncCallback(AutoCompleteCallback), request); } private void AutoCompleteCallback(IAsyncResult callback) { HttpWebRequest request = (HttpWebRequest)callback.AsyncState; HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(callback); // retrieve data using StreamReader }#td2013fi @fincooper
  23. 23. Extension Methods public static Task<HttpWebResponse> GetResponseAsync(this HttpWebRequest request) { var taskComplete = new TaskCompletionSource<HttpWebResponse>(); request.BeginGetResponse(asyncResponse => { HttpWebRequest responseRequest = (HttpWebRequest)asyncResponse.AsyncState; HttpWebResponse someResponse = (HttpWebResponse)responseRequest.EndGetResponse(asyncResponse); taskComplete.TrySetResult(someResponse); }, request); return taskComplete.Task; }#td2013fi @fincooper
  24. 24. HttpWebResponse and HttpWebRequest #if WINDOWS_PHONE using MyExtensionClass #endif var request = (HttpWebRequest)WebRequest.Create(autoCompleteUri); HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync(); // retrieve data using StreamReader Use carefully – performance in ABYSMAL#td2013fi @fincooper
  25. 25. Best practices
  26. 26. Most common reasons to fail certification • Windows Phone: failure to check for (light) themes • Windows 8: no privacy policy#td2013fi @fincooper
  27. 27. Do NOT share XAML. Just don’t.
  28. 28. Different Form Factors Require Different UX#td2013fi @fincooper
  29. 29. Translating UX#td2013fi @fincooper
  30. 30. Translating UX – Details View#td2013fi @fincooper
  31. 31. CaseMoomin video store
  32. 32. Case: Moomin video store• Windows 8 client ported to Windows Phone 8• Core Models and ViewModels unchanged• Azure backend for distributing media (Win8) and keeping track of in-app purchases receipts• Different Store, different in-app purchases• WP: download limitations• Different media players#td2013fi @fincooper
  33. 33. Thank you! Time for QA and a quick raffle!#td2013fi @fincooper

×