SlideShare une entreprise Scribd logo
1  sur  33
Maximizing code reuse between
Windows Phone 8 and Windows 8
Tom Walker
@Tinytoot
orangesodacode.azurewebsites.net
Ken Cenerelli
@KenCenerelli
kencenerelli.wordpress.com
• Part 1: Hardware Overview
 Platform APIs
 Shared Core
• Part 2: Development Techniques
 MVVM project structure
 Portable Class Libraries
 Shared XAML UI
 Sharing Code
• Part 3: Demo – In-depth development for both platforms
• Wrap-up
 Next Steps, Resources & Related Sessions
 Q & A
Agenda
Maximizing code reuse between WP8 and Windows 8
• We are on the path to Windows and Windows Phone
convergence
• Right now Windows 8 and Windows Phone 8 have a
shared core but you cannot write once and run everywhere
(unlike iOS or Android)
• We can however leverage some existing architecture
similarities between the two
Part 1: Hardware Overview
Maximizing code reuse between WP8 and Windows 8
Some Key Differences
• It’s important to design for the platform differences as well
as similarities
Maximizing code reuse between WP8 and Windows 8
Windows 8 Platform
Maximizing code reuse between WP8 and Windows 8
Windows Phone 8 Platform
Maximizing code reuse between WP8 and Windows 8
Shared APIs
Maximizing code reuse between WP8 and Windows 8
What Shared Core Means
• OS components such as the kernel, networking, graphics
support, file system and multimedia are the same on both
Windows 8 and Windows Phone 8
• Hardware manufacturers work with the same driver model
on both platforms
• Windows Phone gets the support for multi-core and other
hardware features that Windows has had for years
• These solid, common foundations makes it easier to extend
the Windows platform into the future
Maximizing code reuse between WP8 and Windows 8
What Shared Core Doesn’t Mean
• Windows 8 and Windows Phone 8 developers work to
exactly the same APIs
 (though you will see more commonality as new features are introduced to
both platforms in the future)
Maximizing code reuse between WP8 and Windows 8
Part 2: Development Techniques
• Four examples of how you can approach code reuse:
 MVVM project structure
 Portable Class Libraries
 Shared XAML UI
 Add As Link (Partial Classes)
• Accelerate your app development with these methods
• Not all will work in every situation
Maximizing code reuse between WP8 and Windows 8
MVVM - Overview
• MVVM is an architectural pattern:
• Relies on features XAML/C# provide
Maximizing code reuse between WP8 and Windows 8
Why use MVVM?
• Loose coupling between UI and code
• Enables reusability
• Separation between UX designer & developer
• Increased testability
Maximizing code reuse between WP8 and Windows 8
MVVM components
• Model
 Data or business logic
 Database, Web Services, File System, etc.
• View Model
 A specialization of the Model that the View uses
 Informs the view to update
 No UI code
• View
 Represents the user interface the user sees
 Should contain a minimal amount of code
Maximizing code reuse between WP8 and Windows 8
MVVM for code reuse
• Create a separate UI for each platform to take advantage of
the different screen sizes
• MVVM by itself doesn’t help us for sharing code across
platforms – only on the same platform
• Use Portable Class Libraries to share models and view
models across platforms
Maximizing code reuse between WP8 and Windows 8
MVVM - Demo• Setting up a project to use MVVM
Maximizing code reuse between WP8 and Windows 8
Demo 1:
MVVM Project Setup
Portable Class Libraries - Overview
• Portable Class Libraries have been available since .NET
Framework 4
• Portable assemblies can target multiple platforms, including
Windows 7, Windows 8, Windows Phone, Silverlight, and
Xbox 360
• Only allowed to call APIs available across multiple
platforms
• Note: the Express versions of Visual Studio 2012 don’t
include a Portable Class Library project template. It is
available only in Visual Studio 2012 Pro or greater
Maximizing code reuse between WP8 and Windows 8
Portable Class Libraries – What To Share
• Any managed code you write, particularly app logic
• Do not share conditional compilation code (code for WP8
that you want to implement differently for Windows 8)
 Instead, abstract away the platform-dependent code and share only the
portable, platform-independent code
• Windows Runtime APIs aren’t portable and can’t be used in
a Portable Class Library
 There is overlap in the Windows Runtime APIs that are supported on WP8
and Windows 8. However, binary compatibility is not supported. Your code
has to be compiled for each platform
• Doesn’t use UI constructs
 Although XAML for WP8 and Windows looks similar this code isn’t portable
Maximizing code reuse between WP8 and Windows 8
Portable Class Libraries & MVVM
Maximizing code reuse between WP8 and Windows 8
Portable Class Libraries - Demo
• Creating a simple Portable Class Library
Maximizing code reuse between WP8 and Windows 8
Demo 2:
Portable Class Library
Shared XAML UI - Overview
• Isolate parts of your UI into user controls and attempt to
share those. Windows Phone 8 and Windows 8 both
support XAML user controls
• New controls take advantage of form factor
• Consider the Windows Phone when designing the Windows
8 SnapView
• Limitations
 XAML on Windows Phone 8 and XAML on Windows 8 is not binary
compatible
 Namespace prefixes are different in XAML for Windows Phone 8 and XAML
for Windows 8
Maximizing code reuse between WP8 and Windows 8
Shared XAML UI – What To Share?
Maximizing code reuse between WP8 and Windows 8
Maximizing code reuse between WP8 and Windows 8
Demo 3:
Shared XAML UI
Sharing Code - Overview
• Change once, Change everywhere
• Approaches:
 Add as Link
 #if conditional blocks
 Partial Classes and Methods
Maximizing code reuse between WP8 and Windows 8
Add As Link - Overview
• Use this technique for any code you’re able to isolate that’s
platform-independent and used in both apps
 eg. User controls with no platform dependencies.
• This is particularly useful when you’re trying to share code
that uses a Windows Runtime API that can’t be shared
inside a Portable Class Library
Maximizing code reuse between WP8 and Windows 8
#if Conditional Blocks - Overview
• Pros:
 Enable/Disable lines or chunks of code based on compilation platform
 Existing compilation constants
 NETFX_CORE Windows 8
 WINDOWS_PHONE Windows Phone 8
 Useful for when there are subtle differences in syntax or methods
• Cons:
 A downside is it can make code unreadable
Maximizing code reuse between WP8 and Windows 8
Partial Classes - Overview
• Can put shared functionality in one code file and platform
specific code in additional code file
• Classes are marked as partial and compiled into a single
class
• Separates platform specific features
• Can use partial methods as a mechanism to separate out
platform specific logic
Maximizing code reuse between WP8 and Windows 8
Maximizing code reuse between WP8 and Windows 8
Demo 4:
Creating a Partial
Class
Part 3: Demo – An app for both platforms
• Technologies Used:
 MVVM Light Toolkit
 Portable Class Library for JSON.NET (NewtonSoft)
 HttpClient for Windows 8 and Windows Phone 8 (release candidate)
 Add As Link
 ComicVine WebAPI
Maximizing code reuse between WP8 and Windows 8
Maximizing code reuse between WP8 and Windows 8
Demo:
Create an app for
both platforms
Actions to continue your learning
• Build a project in both Windows 8 and
Windows Phone 8
• Create a Portable Class Library to link the
two projects
• Choose one other development technique to
extend your code between both projects
Maximizing code reuse between WP8 and Windows 8
Resources for Attendees
• Channel 9: Building Apps for Both Windows 8 and
Windows Phone 8 Jump Start http://bit.ly/18dELOu
• Maximize code reuse between Windows Phone 8
and Windows 8 http://bit.ly/11TfzOl
• How to Make Portable Class Libraries Work for
You http://bit.ly/116yIL4
• Channel 9: Create Cross-platform Apps using
Portable Class Libraries http://bit.ly/1906wv8
Maximizing code reuse between WP8 and Windows 8
Related Sessions
• Architecting mobile apps for Win8, IOS and Android
 Erik Renaud - ARC376
• Building Mobile Experiences that Don't Suck
 Atley Hunter - MOB362
• Designing Windows Store HTML5/JS Apps
 Mark Arteaga - WIN371
• Bringing it all together Win8 WP8 Azure MVC...
 Colin Melia - WIN312
Maximizing code reuse between WP8 and Windows 8
Questions?
• Tom Walker
 @Tinytoot
 orangesodacode.azurewebsites.net
• Ken Cenerelli
 @KenCenerelli
 kencenerelli.wordpress.com
Maximizing code reuse between WP8 and Windows 8

Contenu connexe

Tendances

WPF & Silverlight Intro
WPF & Silverlight IntroWPF & Silverlight Intro
WPF & Silverlight IntroDave Allen
 
Silverlight - What Is It And How Can We Use It
Silverlight - What Is It And How Can We Use ItSilverlight - What Is It And How Can We Use It
Silverlight - What Is It And How Can We Use ItVenketash (Pat) Ramadass
 
Silverlight
SilverlightSilverlight
Silverlightvishakpb
 
Cross platform web app development
Cross platform web app developmentCross platform web app development
Cross platform web app developmenttomasperezv
 
Flex_Basic_Training
Flex_Basic_TrainingFlex_Basic_Training
Flex_Basic_Trainingguest25cec3
 
.Net framework
.Net framework.Net framework
.Net frameworkArun Pal
 
tutorials-visual-studio_visual-studio-2015-preview-comes-with-emulator-for-an...
tutorials-visual-studio_visual-studio-2015-preview-comes-with-emulator-for-an...tutorials-visual-studio_visual-studio-2015-preview-comes-with-emulator-for-an...
tutorials-visual-studio_visual-studio-2015-preview-comes-with-emulator-for-an...Anil Sharma
 
Silverlight difference faqs-1
Silverlight  difference faqs-1Silverlight  difference faqs-1
Silverlight difference faqs-1Umar Ali
 
Visual Studio | Lanzamiento VS2017 en Buenos Aires - 11/03/2017
Visual Studio | Lanzamiento VS2017 en Buenos Aires - 11/03/2017Visual Studio | Lanzamiento VS2017 en Buenos Aires - 11/03/2017
Visual Studio | Lanzamiento VS2017 en Buenos Aires - 11/03/2017Pablo Ariel Di Loreto
 
Building Flash-based websites using Adobe Flex - Lesson 10/10
Building Flash-based websites using Adobe Flex - Lesson 10/10Building Flash-based websites using Adobe Flex - Lesson 10/10
Building Flash-based websites using Adobe Flex - Lesson 10/10Stefano Virgilli
 
Apache Flex: Overview
Apache Flex: OverviewApache Flex: Overview
Apache Flex: OverviewTarun Telang
 
Adobe is from Mars, Microsoft is from Uranus. A look at two competing web st...
Adobe is from Mars, Microsoft is from Uranus.  A look at two competing web st...Adobe is from Mars, Microsoft is from Uranus.  A look at two competing web st...
Adobe is from Mars, Microsoft is from Uranus. A look at two competing web st...Eric Fickes
 
Dot net universal apps
Dot net universal appsDot net universal apps
Dot net universal appssonia merchant
 

Tendances (19)

Explore asp.net core 3.0 features
Explore asp.net core 3.0 featuresExplore asp.net core 3.0 features
Explore asp.net core 3.0 features
 
Presentation[1]
Presentation[1]Presentation[1]
Presentation[1]
 
WPF & Silverlight Intro
WPF & Silverlight IntroWPF & Silverlight Intro
WPF & Silverlight Intro
 
Silverlight - What Is It And How Can We Use It
Silverlight - What Is It And How Can We Use ItSilverlight - What Is It And How Can We Use It
Silverlight - What Is It And How Can We Use It
 
Visual Studio 2012 introduction
Visual Studio  2012 introductionVisual Studio  2012 introduction
Visual Studio 2012 introduction
 
Silverlight
SilverlightSilverlight
Silverlight
 
Cross platform web app development
Cross platform web app developmentCross platform web app development
Cross platform web app development
 
Visual Basic User Interface-III
Visual Basic User Interface-IIIVisual Basic User Interface-III
Visual Basic User Interface-III
 
Flex_Basic_Training
Flex_Basic_TrainingFlex_Basic_Training
Flex_Basic_Training
 
.Net framework
.Net framework.Net framework
.Net framework
 
tutorials-visual-studio_visual-studio-2015-preview-comes-with-emulator-for-an...
tutorials-visual-studio_visual-studio-2015-preview-comes-with-emulator-for-an...tutorials-visual-studio_visual-studio-2015-preview-comes-with-emulator-for-an...
tutorials-visual-studio_visual-studio-2015-preview-comes-with-emulator-for-an...
 
Silverlight difference faqs-1
Silverlight  difference faqs-1Silverlight  difference faqs-1
Silverlight difference faqs-1
 
Silverlight 4
Silverlight 4Silverlight 4
Silverlight 4
 
Visual Studio | Lanzamiento VS2017 en Buenos Aires - 11/03/2017
Visual Studio | Lanzamiento VS2017 en Buenos Aires - 11/03/2017Visual Studio | Lanzamiento VS2017 en Buenos Aires - 11/03/2017
Visual Studio | Lanzamiento VS2017 en Buenos Aires - 11/03/2017
 
Building Flash-based websites using Adobe Flex - Lesson 10/10
Building Flash-based websites using Adobe Flex - Lesson 10/10Building Flash-based websites using Adobe Flex - Lesson 10/10
Building Flash-based websites using Adobe Flex - Lesson 10/10
 
Apache Flex: Overview
Apache Flex: OverviewApache Flex: Overview
Apache Flex: Overview
 
Adobe is from Mars, Microsoft is from Uranus. A look at two competing web st...
Adobe is from Mars, Microsoft is from Uranus.  A look at two competing web st...Adobe is from Mars, Microsoft is from Uranus.  A look at two competing web st...
Adobe is from Mars, Microsoft is from Uranus. A look at two competing web st...
 
Top 6 php framework
Top 6 php frameworkTop 6 php framework
Top 6 php framework
 
Dot net universal apps
Dot net universal appsDot net universal apps
Dot net universal apps
 

Similaire à Maximizing code reuse between Windows Phone 8 and Windows 8 (DevTeach Toronto 2013)

How to modernise WPF and Windows Forms applications with Windows Apps SDK
How to modernise WPF and Windows Forms applications with Windows Apps SDKHow to modernise WPF and Windows Forms applications with Windows Apps SDK
How to modernise WPF and Windows Forms applications with Windows Apps SDKMirco Vanini
 
Eric grover strategies for sharing code with windows 8 and windows phone 8 ...
Eric grover   strategies for sharing code with windows 8 and windows phone 8 ...Eric grover   strategies for sharing code with windows 8 and windows phone 8 ...
Eric grover strategies for sharing code with windows 8 and windows phone 8 ...Eric Grover
 
Windows Phone 8 - introducing wp8 development
Windows Phone 8 - introducing wp8 developmentWindows Phone 8 - introducing wp8 development
Windows Phone 8 - introducing wp8 developmentGouda Mando
 
Overview of .Net Framework
Overview of .Net FrameworkOverview of .Net Framework
Overview of .Net FrameworkNeha Singh
 
Why is .Net Technology Recognised for Software Development?
Why is .Net Technology Recognised for Software Development?Why is .Net Technology Recognised for Software Development?
Why is .Net Technology Recognised for Software Development?LOGINPHP360
 
Building apps for WP8 and Win8
Building apps for WP8 and Win8Building apps for WP8 and Win8
Building apps for WP8 and Win8Laurent Duveau
 
Why is .Net Technology Recognised for Software Development?
Why is .Net Technology Recognised for Software Development?Why is .Net Technology Recognised for Software Development?
Why is .Net Technology Recognised for Software Development?LOGINPHP360
 
Microsoft xamarin-experience
Microsoft xamarin-experienceMicrosoft xamarin-experience
Microsoft xamarin-experienceXpand IT
 
Intro to Microsoft.NET
Intro to Microsoft.NET Intro to Microsoft.NET
Intro to Microsoft.NET rchakra
 
Windows Universal Apps
Windows Universal AppsWindows Universal Apps
Windows Universal AppsJames Quick
 
Difference between .net and asp.net all you need to know
Difference between .net and asp.net  all you need to knowDifference between .net and asp.net  all you need to know
Difference between .net and asp.net all you need to knowsophiaaaddison
 
Three's Company - Writing for the Desktop, Browser, and Phone
Three's Company - Writing for the Desktop, Browser, and PhoneThree's Company - Writing for the Desktop, Browser, and Phone
Three's Company - Writing for the Desktop, Browser, and PhoneSarah Dutkiewicz
 
Sinergija 12 WP8 is around the corner
Sinergija 12 WP8 is around the cornerSinergija 12 WP8 is around the corner
Sinergija 12 WP8 is around the cornerCatalin Gheorghiu
 
Difference between .net core and .net framework
Difference between .net core and .net frameworkDifference between .net core and .net framework
Difference between .net core and .net frameworkAnsi Bytecode
 
.NET Conf 2021 - Hot Topics Desktop Development
.NET Conf 2021 - Hot Topics Desktop Development.NET Conf 2021 - Hot Topics Desktop Development
.NET Conf 2021 - Hot Topics Desktop DevelopmentMirco Vanini
 
.Net framework vs .net core a complete comparison
.Net framework vs .net core  a complete comparison.Net framework vs .net core  a complete comparison
.Net framework vs .net core a complete comparisonKaty Slemon
 
Universal Apps Oct 2014
Universal Apps Oct 2014Universal Apps Oct 2014
Universal Apps Oct 2014Joe Healy
 
.NET Core, ASP.NET Core Course, Session 1
.NET Core, ASP.NET Core Course, Session 1.NET Core, ASP.NET Core Course, Session 1
.NET Core, ASP.NET Core Course, Session 1aminmesbahi
 

Similaire à Maximizing code reuse between Windows Phone 8 and Windows 8 (DevTeach Toronto 2013) (20)

How to modernise WPF and Windows Forms applications with Windows Apps SDK
How to modernise WPF and Windows Forms applications with Windows Apps SDKHow to modernise WPF and Windows Forms applications with Windows Apps SDK
How to modernise WPF and Windows Forms applications with Windows Apps SDK
 
Eric grover strategies for sharing code with windows 8 and windows phone 8 ...
Eric grover   strategies for sharing code with windows 8 and windows phone 8 ...Eric grover   strategies for sharing code with windows 8 and windows phone 8 ...
Eric grover strategies for sharing code with windows 8 and windows phone 8 ...
 
Windows Phone 8 - introducing wp8 development
Windows Phone 8 - introducing wp8 developmentWindows Phone 8 - introducing wp8 development
Windows Phone 8 - introducing wp8 development
 
Overview of .Net Framework
Overview of .Net FrameworkOverview of .Net Framework
Overview of .Net Framework
 
Why is .Net Technology Recognised for Software Development?
Why is .Net Technology Recognised for Software Development?Why is .Net Technology Recognised for Software Development?
Why is .Net Technology Recognised for Software Development?
 
Building apps for WP8 and Win8
Building apps for WP8 and Win8Building apps for WP8 and Win8
Building apps for WP8 and Win8
 
Why is .Net Technology Recognised for Software Development?
Why is .Net Technology Recognised for Software Development?Why is .Net Technology Recognised for Software Development?
Why is .Net Technology Recognised for Software Development?
 
Microsoft xamarin-experience
Microsoft xamarin-experienceMicrosoft xamarin-experience
Microsoft xamarin-experience
 
Intro to Microsoft.NET
Intro to Microsoft.NET Intro to Microsoft.NET
Intro to Microsoft.NET
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Windows Universal Apps
Windows Universal AppsWindows Universal Apps
Windows Universal Apps
 
Difference between .net and asp.net all you need to know
Difference between .net and asp.net  all you need to knowDifference between .net and asp.net  all you need to know
Difference between .net and asp.net all you need to know
 
Three's Company - Writing for the Desktop, Browser, and Phone
Three's Company - Writing for the Desktop, Browser, and PhoneThree's Company - Writing for the Desktop, Browser, and Phone
Three's Company - Writing for the Desktop, Browser, and Phone
 
Best DotNet Training in Delhi
Best   DotNet Training  in DelhiBest   DotNet Training  in Delhi
Best DotNet Training in Delhi
 
Sinergija 12 WP8 is around the corner
Sinergija 12 WP8 is around the cornerSinergija 12 WP8 is around the corner
Sinergija 12 WP8 is around the corner
 
Difference between .net core and .net framework
Difference between .net core and .net frameworkDifference between .net core and .net framework
Difference between .net core and .net framework
 
.NET Conf 2021 - Hot Topics Desktop Development
.NET Conf 2021 - Hot Topics Desktop Development.NET Conf 2021 - Hot Topics Desktop Development
.NET Conf 2021 - Hot Topics Desktop Development
 
.Net framework vs .net core a complete comparison
.Net framework vs .net core  a complete comparison.Net framework vs .net core  a complete comparison
.Net framework vs .net core a complete comparison
 
Universal Apps Oct 2014
Universal Apps Oct 2014Universal Apps Oct 2014
Universal Apps Oct 2014
 
.NET Core, ASP.NET Core Course, Session 1
.NET Core, ASP.NET Core Course, Session 1.NET Core, ASP.NET Core Course, Session 1
.NET Core, ASP.NET Core Course, Session 1
 

Plus de Ken Cenerelli

ASP.NET Core deployment options
ASP.NET Core deployment optionsASP.NET Core deployment options
ASP.NET Core deployment optionsKen Cenerelli
 
No SQL, No Problem: Use Azure DocumentDB
No SQL, No Problem: Use Azure DocumentDBNo SQL, No Problem: Use Azure DocumentDB
No SQL, No Problem: Use Azure DocumentDBKen Cenerelli
 
Azure app service to create web and mobile apps
Azure app service to create web and mobile appsAzure app service to create web and mobile apps
Azure app service to create web and mobile appsKen Cenerelli
 
ASP.NET Core: The best of the new bits
ASP.NET Core: The best of the new bitsASP.NET Core: The best of the new bits
ASP.NET Core: The best of the new bitsKen Cenerelli
 
Analyze Your Code With Visual Studio 2015 Diagnostic Tools
Analyze Your Code With Visual Studio 2015 Diagnostic ToolsAnalyze Your Code With Visual Studio 2015 Diagnostic Tools
Analyze Your Code With Visual Studio 2015 Diagnostic ToolsKen Cenerelli
 
Building high performance software with Microsoft Application Insights
Building high performance software with Microsoft Application InsightsBuilding high performance software with Microsoft Application Insights
Building high performance software with Microsoft Application InsightsKen Cenerelli
 
An Introduction to Universal Windows Apps
An Introduction to Universal Windows AppsAn Introduction to Universal Windows Apps
An Introduction to Universal Windows Apps Ken Cenerelli
 
Build end-to-end video experiences with Azure Media Services
Build end-to-end video experiences with Azure Media ServicesBuild end-to-end video experiences with Azure Media Services
Build end-to-end video experiences with Azure Media ServicesKen Cenerelli
 
Cloud Powered Mobile Apps with Azure
Cloud Powered Mobile Apps with AzureCloud Powered Mobile Apps with Azure
Cloud Powered Mobile Apps with AzureKen Cenerelli
 
Building Windows 8.1 Apps with Mobile Services
Building Windows 8.1 Apps with Mobile ServicesBuilding Windows 8.1 Apps with Mobile Services
Building Windows 8.1 Apps with Mobile ServicesKen Cenerelli
 
An Introduction to Windows Phone 7 Development
An Introduction to Windows Phone 7 DevelopmentAn Introduction to Windows Phone 7 Development
An Introduction to Windows Phone 7 DevelopmentKen Cenerelli
 
Introduction To Umbraco
Introduction To UmbracoIntroduction To Umbraco
Introduction To UmbracoKen Cenerelli
 

Plus de Ken Cenerelli (13)

ASP.NET Core deployment options
ASP.NET Core deployment optionsASP.NET Core deployment options
ASP.NET Core deployment options
 
No SQL, No Problem: Use Azure DocumentDB
No SQL, No Problem: Use Azure DocumentDBNo SQL, No Problem: Use Azure DocumentDB
No SQL, No Problem: Use Azure DocumentDB
 
Azure app service to create web and mobile apps
Azure app service to create web and mobile appsAzure app service to create web and mobile apps
Azure app service to create web and mobile apps
 
ASP.NET Core: The best of the new bits
ASP.NET Core: The best of the new bitsASP.NET Core: The best of the new bits
ASP.NET Core: The best of the new bits
 
Analyze Your Code With Visual Studio 2015 Diagnostic Tools
Analyze Your Code With Visual Studio 2015 Diagnostic ToolsAnalyze Your Code With Visual Studio 2015 Diagnostic Tools
Analyze Your Code With Visual Studio 2015 Diagnostic Tools
 
Azure Data Storage
Azure Data StorageAzure Data Storage
Azure Data Storage
 
Building high performance software with Microsoft Application Insights
Building high performance software with Microsoft Application InsightsBuilding high performance software with Microsoft Application Insights
Building high performance software with Microsoft Application Insights
 
An Introduction to Universal Windows Apps
An Introduction to Universal Windows AppsAn Introduction to Universal Windows Apps
An Introduction to Universal Windows Apps
 
Build end-to-end video experiences with Azure Media Services
Build end-to-end video experiences with Azure Media ServicesBuild end-to-end video experiences with Azure Media Services
Build end-to-end video experiences with Azure Media Services
 
Cloud Powered Mobile Apps with Azure
Cloud Powered Mobile Apps with AzureCloud Powered Mobile Apps with Azure
Cloud Powered Mobile Apps with Azure
 
Building Windows 8.1 Apps with Mobile Services
Building Windows 8.1 Apps with Mobile ServicesBuilding Windows 8.1 Apps with Mobile Services
Building Windows 8.1 Apps with Mobile Services
 
An Introduction to Windows Phone 7 Development
An Introduction to Windows Phone 7 DevelopmentAn Introduction to Windows Phone 7 Development
An Introduction to Windows Phone 7 Development
 
Introduction To Umbraco
Introduction To UmbracoIntroduction To Umbraco
Introduction To Umbraco
 

Dernier

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

Maximizing code reuse between Windows Phone 8 and Windows 8 (DevTeach Toronto 2013)

  • 1. Maximizing code reuse between Windows Phone 8 and Windows 8 Tom Walker @Tinytoot orangesodacode.azurewebsites.net Ken Cenerelli @KenCenerelli kencenerelli.wordpress.com
  • 2. • Part 1: Hardware Overview  Platform APIs  Shared Core • Part 2: Development Techniques  MVVM project structure  Portable Class Libraries  Shared XAML UI  Sharing Code • Part 3: Demo – In-depth development for both platforms • Wrap-up  Next Steps, Resources & Related Sessions  Q & A Agenda Maximizing code reuse between WP8 and Windows 8
  • 3. • We are on the path to Windows and Windows Phone convergence • Right now Windows 8 and Windows Phone 8 have a shared core but you cannot write once and run everywhere (unlike iOS or Android) • We can however leverage some existing architecture similarities between the two Part 1: Hardware Overview Maximizing code reuse between WP8 and Windows 8
  • 4. Some Key Differences • It’s important to design for the platform differences as well as similarities Maximizing code reuse between WP8 and Windows 8
  • 5. Windows 8 Platform Maximizing code reuse between WP8 and Windows 8
  • 6. Windows Phone 8 Platform Maximizing code reuse between WP8 and Windows 8
  • 7. Shared APIs Maximizing code reuse between WP8 and Windows 8
  • 8. What Shared Core Means • OS components such as the kernel, networking, graphics support, file system and multimedia are the same on both Windows 8 and Windows Phone 8 • Hardware manufacturers work with the same driver model on both platforms • Windows Phone gets the support for multi-core and other hardware features that Windows has had for years • These solid, common foundations makes it easier to extend the Windows platform into the future Maximizing code reuse between WP8 and Windows 8
  • 9. What Shared Core Doesn’t Mean • Windows 8 and Windows Phone 8 developers work to exactly the same APIs  (though you will see more commonality as new features are introduced to both platforms in the future) Maximizing code reuse between WP8 and Windows 8
  • 10. Part 2: Development Techniques • Four examples of how you can approach code reuse:  MVVM project structure  Portable Class Libraries  Shared XAML UI  Add As Link (Partial Classes) • Accelerate your app development with these methods • Not all will work in every situation Maximizing code reuse between WP8 and Windows 8
  • 11. MVVM - Overview • MVVM is an architectural pattern: • Relies on features XAML/C# provide Maximizing code reuse between WP8 and Windows 8
  • 12. Why use MVVM? • Loose coupling between UI and code • Enables reusability • Separation between UX designer & developer • Increased testability Maximizing code reuse between WP8 and Windows 8
  • 13. MVVM components • Model  Data or business logic  Database, Web Services, File System, etc. • View Model  A specialization of the Model that the View uses  Informs the view to update  No UI code • View  Represents the user interface the user sees  Should contain a minimal amount of code Maximizing code reuse between WP8 and Windows 8
  • 14. MVVM for code reuse • Create a separate UI for each platform to take advantage of the different screen sizes • MVVM by itself doesn’t help us for sharing code across platforms – only on the same platform • Use Portable Class Libraries to share models and view models across platforms Maximizing code reuse between WP8 and Windows 8
  • 15. MVVM - Demo• Setting up a project to use MVVM Maximizing code reuse between WP8 and Windows 8 Demo 1: MVVM Project Setup
  • 16. Portable Class Libraries - Overview • Portable Class Libraries have been available since .NET Framework 4 • Portable assemblies can target multiple platforms, including Windows 7, Windows 8, Windows Phone, Silverlight, and Xbox 360 • Only allowed to call APIs available across multiple platforms • Note: the Express versions of Visual Studio 2012 don’t include a Portable Class Library project template. It is available only in Visual Studio 2012 Pro or greater Maximizing code reuse between WP8 and Windows 8
  • 17. Portable Class Libraries – What To Share • Any managed code you write, particularly app logic • Do not share conditional compilation code (code for WP8 that you want to implement differently for Windows 8)  Instead, abstract away the platform-dependent code and share only the portable, platform-independent code • Windows Runtime APIs aren’t portable and can’t be used in a Portable Class Library  There is overlap in the Windows Runtime APIs that are supported on WP8 and Windows 8. However, binary compatibility is not supported. Your code has to be compiled for each platform • Doesn’t use UI constructs  Although XAML for WP8 and Windows looks similar this code isn’t portable Maximizing code reuse between WP8 and Windows 8
  • 18. Portable Class Libraries & MVVM Maximizing code reuse between WP8 and Windows 8
  • 19. Portable Class Libraries - Demo • Creating a simple Portable Class Library Maximizing code reuse between WP8 and Windows 8 Demo 2: Portable Class Library
  • 20. Shared XAML UI - Overview • Isolate parts of your UI into user controls and attempt to share those. Windows Phone 8 and Windows 8 both support XAML user controls • New controls take advantage of form factor • Consider the Windows Phone when designing the Windows 8 SnapView • Limitations  XAML on Windows Phone 8 and XAML on Windows 8 is not binary compatible  Namespace prefixes are different in XAML for Windows Phone 8 and XAML for Windows 8 Maximizing code reuse between WP8 and Windows 8
  • 21. Shared XAML UI – What To Share? Maximizing code reuse between WP8 and Windows 8
  • 22. Maximizing code reuse between WP8 and Windows 8 Demo 3: Shared XAML UI
  • 23. Sharing Code - Overview • Change once, Change everywhere • Approaches:  Add as Link  #if conditional blocks  Partial Classes and Methods Maximizing code reuse between WP8 and Windows 8
  • 24. Add As Link - Overview • Use this technique for any code you’re able to isolate that’s platform-independent and used in both apps  eg. User controls with no platform dependencies. • This is particularly useful when you’re trying to share code that uses a Windows Runtime API that can’t be shared inside a Portable Class Library Maximizing code reuse between WP8 and Windows 8
  • 25. #if Conditional Blocks - Overview • Pros:  Enable/Disable lines or chunks of code based on compilation platform  Existing compilation constants  NETFX_CORE Windows 8  WINDOWS_PHONE Windows Phone 8  Useful for when there are subtle differences in syntax or methods • Cons:  A downside is it can make code unreadable Maximizing code reuse between WP8 and Windows 8
  • 26. Partial Classes - Overview • Can put shared functionality in one code file and platform specific code in additional code file • Classes are marked as partial and compiled into a single class • Separates platform specific features • Can use partial methods as a mechanism to separate out platform specific logic Maximizing code reuse between WP8 and Windows 8
  • 27. Maximizing code reuse between WP8 and Windows 8 Demo 4: Creating a Partial Class
  • 28. Part 3: Demo – An app for both platforms • Technologies Used:  MVVM Light Toolkit  Portable Class Library for JSON.NET (NewtonSoft)  HttpClient for Windows 8 and Windows Phone 8 (release candidate)  Add As Link  ComicVine WebAPI Maximizing code reuse between WP8 and Windows 8
  • 29. Maximizing code reuse between WP8 and Windows 8 Demo: Create an app for both platforms
  • 30. Actions to continue your learning • Build a project in both Windows 8 and Windows Phone 8 • Create a Portable Class Library to link the two projects • Choose one other development technique to extend your code between both projects Maximizing code reuse between WP8 and Windows 8
  • 31. Resources for Attendees • Channel 9: Building Apps for Both Windows 8 and Windows Phone 8 Jump Start http://bit.ly/18dELOu • Maximize code reuse between Windows Phone 8 and Windows 8 http://bit.ly/11TfzOl • How to Make Portable Class Libraries Work for You http://bit.ly/116yIL4 • Channel 9: Create Cross-platform Apps using Portable Class Libraries http://bit.ly/1906wv8 Maximizing code reuse between WP8 and Windows 8
  • 32. Related Sessions • Architecting mobile apps for Win8, IOS and Android  Erik Renaud - ARC376 • Building Mobile Experiences that Don't Suck  Atley Hunter - MOB362 • Designing Windows Store HTML5/JS Apps  Mark Arteaga - WIN371 • Bringing it all together Win8 WP8 Azure MVC...  Colin Melia - WIN312 Maximizing code reuse between WP8 and Windows 8
  • 33. Questions? • Tom Walker  @Tinytoot  orangesodacode.azurewebsites.net • Ken Cenerelli  @KenCenerelli  kencenerelli.wordpress.com Maximizing code reuse between WP8 and Windows 8

Notes de l'éditeur

  1. The only true reuse scenario that is currently supported is via a Portable Class Library
  2. - Windows 8 and Windows Phone 8 Share Many Components At The Operating System Level
  3. Created by John GossmanDerived from MVCRequired XAML Data Binding
  4. ViewModel:-The glue that ties the View to the model – the UI to the data- Exposes data from the model that the view can bind toView: Each page shown to a user is a ViewData from model is displayed to userUsing binding
  5. The only true reuse scenario that is currently supported is via a Portable Class Library
  6. Assemblies that target multiple platformsSupport subset of .NET assemblies that target the platforms you choosePCL doesn’t allow any WinRT/WinPRT APIs – only .NET (to get WinRT APIs, you need to link)Pros: Written in managed code, complete reuse with the ability to simply “Add Reference” to the built assembly.Cons: Severe limitations imposed by the need to work across different platforms without targeting. Important features such as INotifyPropertyChanged and Task are missing making it difficult to use in practice.
  7. Show how to reference a PCLThe most common recommendation is to put your models and business logic in a reusable PCL and put your platform-specific view models in the respective User Interface tiers
  8. Demo: Creating a simple Portable Class LibraryUse same project as MVVM one?
  9. - Microsoft insists that sharing XAML is not where you should invest time- Instead, you’ll have much more success structuring your app logic to make it reusable
  10. Majority of UI will be platform specificPortable code can be compiled once and run on WP8 or W8 – anything in PCLCommon code is code that use APIs available to both platforms but not portable (WinRT APIs)B/C code must be compiled for each platform
  11. Demo: Creating a User Control in each projectThis technique limited but it also does not scale well
  12. This strategy is useful for where there are subtle differences (for example a different namespace or slightly different parameters to a method)The biggest issue with this strategy is that it can quite easily make code unreadable and hard to maintain.
  13. This strategy is useful for where there are subtle differences (for example a different namespace or slightly different parameters to a method)The biggest issue with this strategy is that it can quite easily make code unreadable and hard to maintain.
  14. - Demo: Adding a link between two projects OR Create a partial class