• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Do not do more copy and paste between windows store and windows phone apps
 

Do not do more copy and paste between windows store and windows phone apps

on

  • 4,686 views

See more information in pcl.codeplex.com

See more information in pcl.codeplex.com

Statistics

Views

Total Views
4,686
Views on SlideShare
2,509
Embed Views
2,177

Actions

Likes
1
Downloads
25
Comments
0

9 Embeds 2,177

http://www.saramgsilva.com 1911
http://planet.portugal-a-programar.pt 216
http://www.linkedin.com 32
http://abtasty.com 9
https://twitter.com 3
http://translate.googleusercontent.com 3
http://www.codetails.com 1
http://miclark 1
http://plus.url.google.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • MVVM Light Source Code:Open Win8 and WP8 Solution ;Show CodeHow to do “Add as Link” – use the RelayCommand – file is inside the .Net3,5Show directives - RelayCommandParcial class in diferent files. Show the WeakFunc.Win8
  • Creating a empty PCL projectShow the dialog for choose the targetsEdit the targetsShow the subset
  • Be Pragmatic: Develop UX specific to the target platformDon’t attempt to share UX resources (styles, controls, pages etc)Reuse and share code between platforms

Do not do more copy and paste between windows store and windows phone apps Do not do more copy and paste between windows store and windows phone apps Presentation Transcript

  • 35th Meeting in Lisbon - 26/01/2013 http://netponto.org Don´t do more "copy and paste" between Windows Store and Windows Phone Apps Sara Silva
  • Sara SilvaWindows 8 & Windows Phone Developer  MCPD: Windows Developer 3.5  MCTS: WPF 3.5/4.0 and Windows Forms 3.5  Math Degree: Specialization in Computing - DMUCCommunities :
  • Agenda• Introdution• Sharing code files• Portable Class Library• Portable Class Library + MVVM• Libraries• Conclusion
  • Introdution 2 Platforms Pílula WP Pílula Win8 6 projects Galinho WP Galinho Win8 3 applications 24 WP 24 Win8Nota: Same version for WP7.5 and WP8
  • Introdution• Repeated code between projects => 2 times the same task.• Bug in WP => bug in Win8 and vice versa => 2 times the same correction.• Less features.• Less time for others taks.• Cost are double: “If the cost for the company is Y €/hour => 2*Y€/hour” “If the cost is sleep time => Less time sleeping ”• Demotivation for developers.
  • Share code files• Use “Add as Link” to include same files in multiple projects.• Use directives for platform specifications.• Use partial class and partial methods.• Change once, change everywhere. “Reusing code by including code files in multiple projects.”
  • Share code filesUsing directives: It can “generate” • NETFX_CORE Windows 8 code unreadable • WINDOWS_PHONE Windows Phone #if !NETFX_CORE public object Convert(object value, Type targetType, object parameter, CultureInfo culture) #else public object Convert(object value, Type targetType, object parameter, string culture) #endif
  • Share code filesPartial Classes and partial methods• Shared functionality in one code file.• 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. DataSource.cs | DataSource.WP8.cs | DataSource.Win8.cs
  • Share code filesExample, MVVM Light toolkit :
  • “Add as Link”
  • Portable Class LibraryMore help for developing cross-platform applications using. NetFramework, since it allows you to create "portable assemblies"that can be referenced in projects for multiple platforms withoutthe need to make changes.Will contain the lowest common denominator types: • .NET Framework • Silverlight • .NET for Windows Store apps, • Windows Phone • Xbox 360
  • Portable Class LibraryFeatures supported on various platforms *: * .Net Framework greater or equal to 4.0.3
  • Portable Class LibraryThe documentation on MSDN announces support:
  • Portable Class LibraryVisual Studio 2010 (Extention +SP1) and 2012 provides a Portable Class Library project template.“targets” definitions: When create a project Editing the target in a project
  • Portable Class LibraryVisual Studio 2010 (Extenstion +SP1) and 2012 provides a Portable Class Library project template.Result: “ One Source One Project One Binary Multiple Platforms!”
  • Portable Class Library Project
  • Portable Class Library• Not contains types related to UI because the UI behavior differs between the different platforms;• Windows 8 is required for create Windows Store Apps, but is not required for create Portable Class Libraries that supports Windows Store Apps.• Silverlight-based application must ensure that the minimum runtime version required for the application is set to version 4.0.60129.0 or later <param name="minRuntimeVersion" value="4.0.60129.0" />
  • Portable Class Library + MVVM
  • Portable Class Library + MVVMAvailable classes to help MVVM implementation:System.Collections.ObjectModel• ObservableCollection<T> class• ReadOnlyObservableCollection<T> classSystem.Collections.Specialized• INotifyCollectionChanged class• NotifyCollectionChangedAction class• NotifyCollectionChangedEventArgs class• NotifyCollectionChangedEventHandler classSystem.ComponentModel• DataErrorsChangedEventArgs class• INotifyDataErrorInfo class• INotifyPropertyChanged class• System.Windows.Input.ICommand class• All classes in the System.ComponentModel.DataAnnotations namespace
  • Consuming Odata Service
  • Architecture *only external portable libraries
  • Libraries• Microsoft.Bcl.Async Allow to use async/await without .Net Framework 4.5• Portable Toolkit for MVVM Fork from toolkit MVVM Light: Portable.MvvmLightLibs• MvvmCross Library for MVVM in Windows Phone, Windows Store, iOS, and Android• Portable Class Libraries Contrib Portable adapters and APIs• Json.NET JSON framework
  • Conclusion • Separate UI from app logic using the Model-View-ViewModel pattern. • Share portable .NET code in Portable Class Library • “Abstactration pattern is the key” • Dependency injection allow to encapsulate platform specifications. • Use common Windows Runtime API (Add as Link) • If necessary, extend shared classes to add specific functionality of the platform. • When we want to share code, designing the architecture should bear this in mind!
  • Q&A
  • References• Cross-Platform Development with the .NET Framework• Using Portable Class Library with Model-View-View Model• Create Cross-platform Apps using Portable Class Libraries• Building Apps for Windows Phone 8 Jump Start (MVA)• Visual Studio Toolbox:Portable Class Libraries• Create a Continuous Client Using Portable Class Libraries• How to Leverage your Code across WP8 and Windows 8• Portable Library Articles series by Jeremy Likness• How to Make Portable Class Libraries Work for You• Portable Class Library Enlightenment / Adaptation• Portable Class Libraries – Net Framework 4.0• Portable Class Libraries – Net Framework 4.5
  • Others Samples• PortableNotepad - This sample shows how to access non-portable functionality from portable code by creating a portable abstraction with platform-specific implementations. Goals: Abstraction for Load / Save data in files Projects: Windows Phone, Windows Store App, WPF App• ContosoHelpdesk – This demo show advanced concepts. Goals: Navigation, inversion of control, and synchronizing data across multiple clients with Windows Azure Service Bus. Projects: Windows Phone, Windows Store App Note: Use Autofac portable library (IoC Container)• TwitterSearch – This sample shows how to create a twitter search client. Goals: Twitter Search API, Azure Mobile Services, Projects: Windows Phone, Windows Store App, Console App Note: Use MVVMCross portable library• Disentanglement - This is a solver for Thinkfuns Gordians Knot puzzle which runs on Windows and Windows Phone. It uses a Portable Class Library to share the solver code between the different platforms Goals: Share the solver code. Projects: Windows Phone App, Desktop App, Xbox App• PixPresenter - is a photo sharing app that enables you to connect to another device using Proximity (NFC) and a tap gesture, and then send pictures back and forth between the connected devices. It demonstrates code sharing techniques that you can use when developing an app for bot Goals: Windows Runtime API common code Projects: Windows Phone, Windows Store App (C# and C++)
  • Sponsors “GOLD” Twitter: @PTMicrosoft http://www.microsoft.com/portugal
  • Sponsors “Silver”
  • Sponsors “Bronze”
  • Upcoming meetings• 23/02/2013 – February (Lisbon) 16/03/2013 – March (Lisbon) Reserve these days! :)
  • Thanks!Sara Silvageral@saramgsilva.comhttp://www.saramgsilva.comhttp://twitter.com/saramgsilvahttp://pt.linkedin.com/in/saramgsilvahttp://www.facebook.com/saramgsilva