SlideShare a Scribd company logo
Maximizing code reuse between
Windows Phone 8 and Windows 8
Ken Cenerelli
@KenCenerelli
kencenerelli.wordpress.com
Agenda
• Part 1: Hardware Overview
• PlatformAPIs
• SharedCore
• Part 2: DevelopmentTechniques
• MVVM Project Structure
• PortableClass Libraries
• Shared XAML UI
• SharingCode with Partial Classes
• Wrap-up
• Next Steps, Resources & Q & A
Part 1: Hardware Overview
• We are on the path toWindows andWindows
Phone convergence
• Right nowWindows 8 andWindows 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
Some Key Differences
• It’s important to design for the platform
differences as well as similarities
Windows 8 Platform
Windows Phone 8 Platform
Shared APIs
What Shared Core Means
• OS components such as the kernel, networking,
graphics support, file system and multimedia are
the same on bothWindows 8 andWindows 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
What Shared Core Doesn’t Mean
• Windows 8 andWindows 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)
Part 2: Development Techniques
• Four examples of how you can approach code
reuse:
• MVVM project structure
• PortableClass Libraries
• Shared XAML UI
• Add As Link (Partial Classes)
• Accelerate your app development with these
methods
• Not all will work in every situation
MVVM - Overview
• MVVM is an architectural pattern:
• Relies on features XAML/C# provide
Why use MVVM?
• Loose coupling between UI and code
• Enables reusability
• Separation between UX designer & developer
• Increased testability
MVVM components
• Model
• Data or business logic
• Database,Web Services, File System, etc.
• View Model
• A specialization of the Model that theView uses
• Informs the view to update
• No UI code
• View
• Represents the user interface the user sees
• Should contain a minimal amount of code
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
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,
includingWindows 7,Windows 8,Windows Phone,
Silverlight, and Xbox 360
• Only allowed to call APIs available across multiple
platforms
• Note: the Express versions ofVisual Studio 2012
don’t include a Portable Class Library project
template. It is available only inVisual Studio 2012
Pro or greater
Portable Class Libraries – What
To Share
• Any managed code you write, particularly app logic
• Do not share conditional compilation code (code forWP8 that
you want to implement differently forWindows 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
PortableClass Library
• There is overlap in theWindows RuntimeAPIs that are supported on
WP8 andWindows 8. However, binary compatibility is not supported.
Your code has to be compiled for each platform
• Doesn’t use UI constructs
• AlthoughXAML forWP8 andWindows looks similar this code isn’t
portable
Portable Class Libraries & MVVM
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 factors
• Consider the Windows Phone when designing the
Windows 8 SnapView
• Limitations
• XAML onWindows Phone 8 and XAML onWindows 8 is not
binary compatible
• Namespace prefixes are different in XAML forWindows
Phone 8 and XAML forWindows 8
Shared XAML UI – What To
Share?
Demo 3:
Shared XAML UI
Sharing Code - Overview
• Change once, Change everywhere
• Approaches:
• Add as Link
• #if conditional blocks
• PartialClasses and Methods
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 aWindows Runtime API that
can’t be shared inside a Portable Class Library
#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
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
Demo 4:
Creating a Partial Class
Actions to continue your learning
• Build a project in bothWindows 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
Resources for Attendees
• Channel 9: Building Apps for BothWindows 8
andWindows Phone 8 Jump Start
http://bit.ly/18dELOu
• Maximize code reuse betweenWindows Phone
8 and Windows 8 http://bit.ly/11TfzOl
• How to Make Portable Class LibrariesWork for
You http://bit.ly/116yIL4
• Channel 9: Create Cross-platformApps using
PortableClass Libraries http://bit.ly/1906wv8
Questions?
• Ken_Cenerelli@Outlook.com
• @KenCenerelli
• kencenerelli.wordpress.com

More Related Content

What's hot

Silverlight
SilverlightSilverlight
Silverlight
BiTWiSE
 
Best DotNet Training in Delhi
Best   DotNet Training  in DelhiBest   DotNet Training  in Delhi
Best DotNet Training in Delhi
Information Technology
 
Evolution of .net frame work
Evolution of .net frame workEvolution of .net frame work
Evolution of .net frame work
vc7722
 
C# code sharing across the platforms
C# code sharing across the platformsC# code sharing across the platforms
C# code sharing across the platforms
Andrei Marukovich
 
Visual Studio 2012 introduction
Visual Studio  2012 introductionVisual Studio  2012 introduction
Visual Studio 2012 introduction
Nicko Satria Consulting
 
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
Mirco Vanini
 
Microsoft .Net Technology
Microsoft .Net TechnologyMicrosoft .Net Technology
Microsoft .Net Technology
vijayakumari kaliannan
 
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
 
.NET Framework
.NET Framework.NET Framework
.NET Framework
vijayakumari kaliannan
 
Building apps for WP8 and Win8
Building apps for WP8 and Win8Building apps for WP8 and Win8
Building apps for WP8 and Win8
Laurent Duveau
 
MsNetwork2011 -How to build extensible silverlight application using MEF
MsNetwork2011 -How to build extensible silverlight application using MEFMsNetwork2011 -How to build extensible silverlight application using MEF
MsNetwork2011 -How to build extensible silverlight application using MEFRadenko Zec
 
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
Antonio Chagoury
 
Introduction to WPF
Introduction to WPFIntroduction to WPF
Introduction to WPF
Munish Arora
 
Wpf 1
Wpf 1Wpf 1
C# on a CHIPs
C# on a CHIPsC# on a CHIPs
C# on a CHIPs
Mirco Vanini
 
.NET Framework 4.0 – Changes & Benefits
.NET Framework 4.0 – Changes & Benefits .NET Framework 4.0 – Changes & Benefits
.NET Framework 4.0 – Changes & Benefits
Deepika Chaudhary
 
.Net Overview -- Training (Lesson 1)
.Net Overview -- Training (Lesson 1).Net Overview -- Training (Lesson 1)
.Net Overview -- Training (Lesson 1)Rishi Kothari
 
Silverlight abhinav - slideshare
Silverlight   abhinav - slideshareSilverlight   abhinav - slideshare
Silverlight abhinav - slideshare
abhinav4133
 
DotNet Framework
DotNet FrameworkDotNet Framework
DotNet Framework
Wani Zahoor
 
Dotnet Basics Presentation
Dotnet Basics PresentationDotnet Basics Presentation
Dotnet Basics Presentation
Sudhakar Sharma
 

What's hot (20)

Silverlight
SilverlightSilverlight
Silverlight
 
Best DotNet Training in Delhi
Best   DotNet Training  in DelhiBest   DotNet Training  in Delhi
Best DotNet Training in Delhi
 
Evolution of .net frame work
Evolution of .net frame workEvolution of .net frame work
Evolution of .net frame work
 
C# code sharing across the platforms
C# code sharing across the platformsC# code sharing across the platforms
C# code sharing across the platforms
 
Visual Studio 2012 introduction
Visual Studio  2012 introductionVisual Studio  2012 introduction
Visual Studio 2012 introduction
 
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
 
Microsoft .Net Technology
Microsoft .Net TechnologyMicrosoft .Net Technology
Microsoft .Net Technology
 
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
 
.NET Framework
.NET Framework.NET Framework
.NET Framework
 
Building apps for WP8 and Win8
Building apps for WP8 and Win8Building apps for WP8 and Win8
Building apps for WP8 and Win8
 
MsNetwork2011 -How to build extensible silverlight application using MEF
MsNetwork2011 -How to build extensible silverlight application using MEFMsNetwork2011 -How to build extensible silverlight application using MEF
MsNetwork2011 -How to build extensible silverlight application using MEF
 
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
 
Introduction to WPF
Introduction to WPFIntroduction to WPF
Introduction to WPF
 
Wpf 1
Wpf 1Wpf 1
Wpf 1
 
C# on a CHIPs
C# on a CHIPsC# on a CHIPs
C# on a CHIPs
 
.NET Framework 4.0 – Changes & Benefits
.NET Framework 4.0 – Changes & Benefits .NET Framework 4.0 – Changes & Benefits
.NET Framework 4.0 – Changes & Benefits
 
.Net Overview -- Training (Lesson 1)
.Net Overview -- Training (Lesson 1).Net Overview -- Training (Lesson 1)
.Net Overview -- Training (Lesson 1)
 
Silverlight abhinav - slideshare
Silverlight   abhinav - slideshareSilverlight   abhinav - slideshare
Silverlight abhinav - slideshare
 
DotNet Framework
DotNet FrameworkDotNet Framework
DotNet Framework
 
Dotnet Basics Presentation
Dotnet Basics PresentationDotnet Basics Presentation
Dotnet Basics Presentation
 

Similar to Maximizing code reuse between Windows Phone 8 and Windows 8 (That Conference 2013)

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
Ansi Bytecode
 
Building apps with common code for windows 8 and windows phone 8 (WP8)
Building apps with common code for windows 8 and windows phone 8 (WP8)Building apps with common code for windows 8 and windows phone 8 (WP8)
Building apps with common code for windows 8 and windows phone 8 (WP8)
Tamir Dresher
 
.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
aminmesbahi
 
Introduction_to_NET.ppt
Introduction_to_NET.pptIntroduction_to_NET.ppt
Introduction_to_NET.ppt
Darwin Terraza
 
Vb.net session 01
Vb.net session 01Vb.net session 01
Vb.net session 01Niit Care
 
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
sophiaaaddison
 
Cross Platform Apps with Windows 8 & Windows Phone 8
Cross Platform Apps with Windows 8 & Windows Phone 8Cross Platform Apps with Windows 8 & Windows Phone 8
Cross Platform Apps with Windows 8 & Windows Phone 8
Brent Edwards
 
Modified.net overview
Modified.net overviewModified.net overview
Modified.net overviewFaisal Aziz
 
Develop business apps cross-platform development using visual studio with x...
Develop business apps   cross-platform development using visual studio with x...Develop business apps   cross-platform development using visual studio with x...
Develop business apps cross-platform development using visual studio with x...
Alexander Meijers
 
eSoftHead - groupware solution
eSoftHead - groupware solutioneSoftHead - groupware solution
eSoftHead - groupware solution
Nguyen Hai
 
Introduction to dot net
Introduction to dot netIntroduction to dot net
Introduction to dot net
QIANG XU
 
Dot Net Framework An Overview
Dot Net Framework   An OverviewDot Net Framework   An Overview
Dot Net Framework An OverviewMicrosoftFeed
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
SubashiniRathinavel
 
Universal Apps Oct 2014
Universal Apps Oct 2014Universal Apps Oct 2014
Universal Apps Oct 2014
Joe Healy
 
C# everywhere: Xamarin and cross platform development
C# everywhere: Xamarin and cross platform developmentC# everywhere: Xamarin and cross platform development
C# everywhere: Xamarin and cross platform development
Gill Cleeren
 
Top 10 web application development frameworks 2016
Top 10 web application development frameworks 2016Top 10 web application development frameworks 2016
Top 10 web application development frameworks 2016
iMOBDEV Technologies Pvt. Ltd.
 
Microsoft xamarin-experience
Microsoft xamarin-experienceMicrosoft xamarin-experience
Microsoft xamarin-experienceXpand IT
 
.net Based Component Technologies
.net Based Component Technologies.net Based Component Technologies
.net Based Component Technologies
prakashk453625
 
Create Cross Platform Apps with Portable Class Libraries
Create Cross Platform Apps with Portable Class LibrariesCreate Cross Platform Apps with Portable Class Libraries
Create Cross Platform Apps with Portable Class Libraries
Karthikeyan Anbarasan (AK)
 

Similar to Maximizing code reuse between Windows Phone 8 and Windows 8 (That Conference 2013) (20)

Lecture 10
Lecture 10Lecture 10
Lecture 10
 
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
 
Building apps with common code for windows 8 and windows phone 8 (WP8)
Building apps with common code for windows 8 and windows phone 8 (WP8)Building apps with common code for windows 8 and windows phone 8 (WP8)
Building apps with common code for windows 8 and windows phone 8 (WP8)
 
.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
 
Introduction_to_NET.ppt
Introduction_to_NET.pptIntroduction_to_NET.ppt
Introduction_to_NET.ppt
 
Vb.net session 01
Vb.net session 01Vb.net session 01
Vb.net session 01
 
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
 
Cross Platform Apps with Windows 8 & Windows Phone 8
Cross Platform Apps with Windows 8 & Windows Phone 8Cross Platform Apps with Windows 8 & Windows Phone 8
Cross Platform Apps with Windows 8 & Windows Phone 8
 
Modified.net overview
Modified.net overviewModified.net overview
Modified.net overview
 
Develop business apps cross-platform development using visual studio with x...
Develop business apps   cross-platform development using visual studio with x...Develop business apps   cross-platform development using visual studio with x...
Develop business apps cross-platform development using visual studio with x...
 
eSoftHead - groupware solution
eSoftHead - groupware solutioneSoftHead - groupware solution
eSoftHead - groupware solution
 
Introduction to dot net
Introduction to dot netIntroduction to dot net
Introduction to dot net
 
Dot Net Framework An Overview
Dot Net Framework   An OverviewDot Net Framework   An Overview
Dot Net Framework An Overview
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Universal Apps Oct 2014
Universal Apps Oct 2014Universal Apps Oct 2014
Universal Apps Oct 2014
 
C# everywhere: Xamarin and cross platform development
C# everywhere: Xamarin and cross platform developmentC# everywhere: Xamarin and cross platform development
C# everywhere: Xamarin and cross platform development
 
Top 10 web application development frameworks 2016
Top 10 web application development frameworks 2016Top 10 web application development frameworks 2016
Top 10 web application development frameworks 2016
 
Microsoft xamarin-experience
Microsoft xamarin-experienceMicrosoft xamarin-experience
Microsoft xamarin-experience
 
.net Based Component Technologies
.net Based Component Technologies.net Based Component Technologies
.net Based Component Technologies
 
Create Cross Platform Apps with Portable Class Libraries
Create Cross Platform Apps with Portable Class LibrariesCreate Cross Platform Apps with Portable Class Libraries
Create Cross Platform Apps with Portable Class Libraries
 

More from Ken Cenerelli

ASP.NET Core deployment options
ASP.NET Core deployment optionsASP.NET Core deployment options
ASP.NET Core deployment options
Ken 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 DocumentDB
Ken 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 apps
Ken 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 bits
Ken 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 Tools
Ken Cenerelli
 
Azure Data Storage
Azure Data StorageAzure Data Storage
Azure Data Storage
Ken 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 Insights
Ken 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 Services
Ken Cenerelli
 
Cloud Powered Mobile Apps with Azure
Cloud Powered Mobile Apps with AzureCloud Powered Mobile Apps with Azure
Cloud Powered Mobile Apps with Azure
Ken 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 Services
Ken 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 Umbraco
Ken Cenerelli
 

More from 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
 

Recently uploaded

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 

Recently uploaded (20)

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 

Maximizing code reuse between Windows Phone 8 and Windows 8 (That Conference 2013)

  • 1. Maximizing code reuse between Windows Phone 8 and Windows 8 Ken Cenerelli @KenCenerelli kencenerelli.wordpress.com
  • 2. Agenda • Part 1: Hardware Overview • PlatformAPIs • SharedCore • Part 2: DevelopmentTechniques • MVVM Project Structure • PortableClass Libraries • Shared XAML UI • SharingCode with Partial Classes • Wrap-up • Next Steps, Resources & Q & A
  • 3. Part 1: Hardware Overview • We are on the path toWindows andWindows Phone convergence • Right nowWindows 8 andWindows 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
  • 4. Some Key Differences • It’s important to design for the platform differences as well as similarities
  • 6. Windows Phone 8 Platform
  • 8. What Shared Core Means • OS components such as the kernel, networking, graphics support, file system and multimedia are the same on bothWindows 8 andWindows 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
  • 9. What Shared Core Doesn’t Mean • Windows 8 andWindows 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)
  • 10. Part 2: Development Techniques • Four examples of how you can approach code reuse: • MVVM project structure • PortableClass Libraries • Shared XAML UI • Add As Link (Partial Classes) • Accelerate your app development with these methods • Not all will work in every situation
  • 11. MVVM - Overview • MVVM is an architectural pattern: • Relies on features XAML/C# provide
  • 12. Why use MVVM? • Loose coupling between UI and code • Enables reusability • Separation between UX designer & developer • Increased testability
  • 13. MVVM components • Model • Data or business logic • Database,Web Services, File System, etc. • View Model • A specialization of the Model that theView uses • Informs the view to update • No UI code • View • Represents the user interface the user sees • Should contain a minimal amount of code
  • 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
  • 16. Portable Class Libraries - Overview • Portable Class Libraries have been available since .NET Framework 4 • Portable assemblies can target multiple platforms, includingWindows 7,Windows 8,Windows Phone, Silverlight, and Xbox 360 • Only allowed to call APIs available across multiple platforms • Note: the Express versions ofVisual Studio 2012 don’t include a Portable Class Library project template. It is available only inVisual Studio 2012 Pro or greater
  • 17. Portable Class Libraries – What To Share • Any managed code you write, particularly app logic • Do not share conditional compilation code (code forWP8 that you want to implement differently forWindows 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 PortableClass Library • There is overlap in theWindows RuntimeAPIs that are supported on WP8 andWindows 8. However, binary compatibility is not supported. Your code has to be compiled for each platform • Doesn’t use UI constructs • AlthoughXAML forWP8 andWindows looks similar this code isn’t portable
  • 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 factors • Consider the Windows Phone when designing the Windows 8 SnapView • Limitations • XAML onWindows Phone 8 and XAML onWindows 8 is not binary compatible • Namespace prefixes are different in XAML forWindows Phone 8 and XAML forWindows 8
  • 21. Shared XAML UI – What To Share?
  • 23. Sharing Code - Overview • Change once, Change everywhere • Approaches: • Add as Link • #if conditional blocks • PartialClasses and Methods
  • 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 aWindows Runtime API that can’t be shared inside a Portable Class Library
  • 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
  • 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
  • 27. Demo 4: Creating a Partial Class
  • 28. Actions to continue your learning • Build a project in bothWindows 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
  • 29. Resources for Attendees • Channel 9: Building Apps for BothWindows 8 andWindows Phone 8 Jump Start http://bit.ly/18dELOu • Maximize code reuse betweenWindows Phone 8 and Windows 8 http://bit.ly/11TfzOl • How to Make Portable Class LibrariesWork for You http://bit.ly/116yIL4 • Channel 9: Create Cross-platformApps using PortableClass Libraries http://bit.ly/1906wv8

Editor's Notes

  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. - 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
  9. 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
  10. 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.
  11. 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.