SlideShare a Scribd company logo
Cross platform mobile apps using .NETJonas FollesøNDC, June 2011
AGENDA:Why?
8 techniques
Complete examplehttp://www.flickr.com/photos/20792787@N00/2248623391/
Cross platform mobile apps using .NET
Cross platform mobile apps using .NET
TILE FLOOD
TILE FLOOD
Cross platform mobile apps using .NET
Why cross platform..?
REUSE SKILL SET?
REUSE CODE?privatevoidopen_Click(objectsender, RoutedEventArgse){varchannel=HttpNotificationChannel.Find("NNUG");if (channel==null)    {channel=newHttpNotificationChannel("NNUG");                  }channel.ChannelUriUpdated+=channel_ChannelUriUpdated;channel.ShellToastNotificationReceived+=channel_ShellToastNotificationReceived;channel.Open();}
REUSE LIBRARIES+35 libraries monotouch.info/MonoTouch/LibrariesCOST OF MAINTAINING MULTIPLE CODE BASES
LIKE C#..?
... OR DISLIKE THE ALTERNATIVE
OBJECTIVE-C: DATE (NO TIME)+ (NSDate *) stripTime:(NSDate *) date {NSCalendar *gregorian =         [[NSCalendaralloc] initWithCalendarIdentifier:NSGregorianCalendar];NSDateComponents *components =        [gregorian components:            (NSYearCalendarUnit | NSMonthCalendarUnit |NSDayCalendarUnit)fromDate:date];    date = [gregoriandateFromComponents:components];    [gregorian release];    return date;}
C#:  DATE (NO TIME)public DateTimeStripTime(DateTime date){    return date.Date;}
Cross platform mobile apps using .NET
TECHNIQUE 1:PORTABLE CLASS LIBRARY
HELP YOU STICK TO A COMMON SUBSET
PORTABLE CLASS LIBRARYPROSOne class library for all platforms
Helps you stick to a common subsetCONSNo Preprocessor Directives
No Platform Specific Code in Class Lib
Not directly supported on MonoDevelop yetTECHNIQUE 2:LINKED FILES
WORKS IN MONODEVELOP
LINKED FILESPROSSame code across all platforms
Ability to  add platform specific code
Preprocessor DirectivesCONSNeed to manage multiple projectsTECHNIQUE 3:LINK FILES USING  «PROJECT LINKER»
PROJECT LINKERPROSAuto link files between projectsCONSDoes not work in MonoDevelop
Must have all projects in same solutionTECHNIQUE 4:VSMonoTouch Open MonoTouch projects in VS2010
VSMonoTouchPROSOpen and build (verify) MonoTouch in VS2010CONSNot a «real» build
Some manual steps involvedTECHNIQUE 5:PREPROCESSOR DIRECTIVES
using System.Net;#if MONOTOUCH || MONODROIDusing System.Web;#endif
PREPROCESSOR DIRECTIVESPROSEasily write platform specific codeCONSCode smell
DRY – The #ifdefs tend to spreaddemo
TECHNIQUE 6:ABSTRACT COMMONFUNCTIONALITY
publicinterfaceIDispatchOnUIThread{void Invoke(Action action);}
// Windows Phone 7publicclassDispatchAdapter : IDispatchOnUIThread{publicvoid Invoke(Action action)    {Deployment.Current.Dispatcher.BeginInvoke(action);    }}
// Mono for AndroidpublicclassDispatchAdapter : IDispatchOnUIThread{privatereadonlyActivity _owner;public DispatchAdapter(Activity owner)    {        _owner = owner;    }publicvoid Invoke(Action action)    {        _owner.RunOnUiThread(action);    }}
// MonotouchpublicclassDispatchAdapter : IDispatchOnUIThread{	privatereadonly NSObject _owner;	publicDispatchAdapter(NSObject owner)	{		_owner = owner;	}	publicvoid Invoke (Action action)	{		_owner.BeginInvokeOnMainThread(newNSAction(action));}}
ABSTRACT FUNCTIONALITYPROSShare even more code
Do not need preprocessor directivesCONSMore abstractions in codeTECHNIQUE 7:LEVERAGE MVVM ON ALL PLATFORMS
Ensure that any code that manipulates presentation only manipulates presentation, pushing all domain and data source logic into clearly separated areas of the program.Martin Fowler, Separated Presentation, July 2006
Cross platform mobile apps using .NET
Separated Presentation Patterns
Data & Domain Logic(Model)UI(View)Interaction (Controller/Presenter)
MVVMPATTERN FOR BINDABLE UI
APP LOGIC IN CODE BEHIND IS HARD TO TEST AND MAINTAINVIEWXAMLDataModelCode-BehindEventHandlers
SEPARATE USINGMVVMVIEWXAMLCode-BehindChange notificationData-binding and commandsVIEW MODELData ModelState + Operations
publicclassObservableAdapter<T> : BaseAdapter<T>{privatereadonlyActivity _context;privatereadonlyObservableCollection<T> _collection;publicObservableAdapter(Activitycontext, ObservableCollection<T> collection)    {        _context = context;        _collection = collection;        _collection.CollectionChanged += (o, e) => 							NotifyDataSetChanged();}...ListAdapter = newObservableAdapter<Airport>				(this, _viewModel.Airports);
publicabstractclassObservableDataSource<T> : UITableViewDataSource{	publicObservableDataSource (ObservableCollection<T> 						collection, UITableView tableView)	{		_tableView = tableView;		_collection = collection;		_collection.CollectionChanged += (o, e) => {			tableView.ReloadData();		};	}...
APPLYING MVVMPROSShare even more code
Testable View ModelsCONSMore abstractions in code
May not feel natural to platformdemo
TECHNIQUE 8:USE PRE-BUILT ABSTRACTIONS
PHONE SPECIFIC APIS?http://www.flickr.com/photos/howzey/2880455762/
EXAMPLESAccelerometer
Camera
Compass
Geolocation
Notification
Storage
Contacts
And more...MonoMobile.Extensionshttps://github.com/chrisntr/MonoMobile.Extensions

More Related Content

PDF
Building with Firebase
PDF
Using google appengine
PDF
Cloud focker を試してみた public
PDF
Angular is one fire(base)! - Shmuela Jacobs
PDF
"13 ways to run web applications on the Internet" Andrii Shumada
PPTX
Provisioning, deploying and debugging node.js applications on azure
PDF
Зоопарк React-у
PDF
Node Summit 2018: Cloud Native Node.js
Building with Firebase
Using google appengine
Cloud focker を試してみた public
Angular is one fire(base)! - Shmuela Jacobs
"13 ways to run web applications on the Internet" Andrii Shumada
Provisioning, deploying and debugging node.js applications on azure
Зоопарк React-у
Node Summit 2018: Cloud Native Node.js

What's hot (20)

PPTX
Node.js kubernetes-cloud all the buzzwords coming together with microsoft azure
PPTX
Blazor and Azure Functions - a serverless approach
PPTX
Athena, Android UI Testing Platfrom
PPTX
Seattle Code Camp 2016 - .Net Core
PDF
Bridge the Dev/Production Gap with Docker
PDF
"Building a Production-Grade Serverless Deployment" - Eoin Shanaghy, CTO, fo...
PDF
DevOps Days Kyiv 2019 -- What you see is what you get for AWS // Anton Babenko
PDF
OpenShift: Java EE in the clouds
PPTX
Azure Fast 7 - The Fastest & Easiest way to get your Web apps onto Azure
PDF
Play on Docker
PDF
Aegir Fresno Drupal User Group 1-21-10
PDF
Appenginejs (old presentation)
PDF
Deploy Angular to the Cloud (ngBucharest)
PDF
Kubernetes and the 12 factor cloud apps
PDF
Was is Docker? Or: Docker for Software Developers
PDF
Fastlane - Automation and Continuous Delivery for iOS Apps
PPTX
Ultimate Productivity Tools
PDF
Docker Tooling for Eclipse
PDF
Advanced front-end automation with npm scripts
PPTX
15-ways-to-optimize-spring-boot-for-the-cloud
Node.js kubernetes-cloud all the buzzwords coming together with microsoft azure
Blazor and Azure Functions - a serverless approach
Athena, Android UI Testing Platfrom
Seattle Code Camp 2016 - .Net Core
Bridge the Dev/Production Gap with Docker
"Building a Production-Grade Serverless Deployment" - Eoin Shanaghy, CTO, fo...
DevOps Days Kyiv 2019 -- What you see is what you get for AWS // Anton Babenko
OpenShift: Java EE in the clouds
Azure Fast 7 - The Fastest & Easiest way to get your Web apps onto Azure
Play on Docker
Aegir Fresno Drupal User Group 1-21-10
Appenginejs (old presentation)
Deploy Angular to the Cloud (ngBucharest)
Kubernetes and the 12 factor cloud apps
Was is Docker? Or: Docker for Software Developers
Fastlane - Automation and Continuous Delivery for iOS Apps
Ultimate Productivity Tools
Docker Tooling for Eclipse
Advanced front-end automation with npm scripts
15-ways-to-optimize-spring-boot-for-the-cloud
Ad

Similar to Cross platform mobile apps using .NET (20)

PDF
Sharing up to 80% code for iOS, Android, and Windows platforms, a Retail App ...
PDF
Three's Company - Writing for the Desktop, Browser, and Phone
PPTX
Cross platform mobile app development with Xamarin
KEY
Cross Platform Development with Xamarin
PPT
Cross-Platform Mobile Development in Visual Studio
PPTX
App innovationcircles xamarin
PPTX
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
PPTX
Dia 1 intro to mobile and xamarin
PPTX
Shape 2013 developing multi targeting windows store and windows phone apps
PPTX
Introduction to MonoTouch
PDF
Introduction to MonoTouch and Monodroid/Mono for Android
PPTX
Iasi code camp 12 october 2013 adrian marinica - windows 8 and windows phon...
PPTX
Develop business apps cross-platform development using visual studio with x...
PDF
Portable Class Libraries and MVVM
PPTX
MonoTouch 5.2 Introduction
PPTX
Eco system apps
PDF
MvvmCross Introduction
PDF
MvvmCross Seminar
PPTX
C# everywhere: Xamarin and cross platform development
PPTX
Windows Phone 7 Architecture Overview
Sharing up to 80% code for iOS, Android, and Windows platforms, a Retail App ...
Three's Company - Writing for the Desktop, Browser, and Phone
Cross platform mobile app development with Xamarin
Cross Platform Development with Xamarin
Cross-Platform Mobile Development in Visual Studio
App innovationcircles xamarin
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Dia 1 intro to mobile and xamarin
Shape 2013 developing multi targeting windows store and windows phone apps
Introduction to MonoTouch
Introduction to MonoTouch and Monodroid/Mono for Android
Iasi code camp 12 october 2013 adrian marinica - windows 8 and windows phon...
Develop business apps cross-platform development using visual studio with x...
Portable Class Libraries and MVVM
MonoTouch 5.2 Introduction
Eco system apps
MvvmCross Introduction
MvvmCross Seminar
C# everywhere: Xamarin and cross platform development
Windows Phone 7 Architecture Overview
Ad

More from Jonas Follesø (13)

PPTX
Introduction to F#
PPT
Hvordan lage en vellykket Windows Phone 7 App
PPTX
Hvordan lage en vellykket WP7 applikasjon
PPTX
Why learn new programming languages
PPTX
Smidig 2011 TDD Workshop
PPTX
An overview of the Windows Phone 7 platform
PPTX
Windows Phone 7 lyntale fra Grensesnittet Desember 2010
PPTX
NNUG Trondheim 30.09.2010 - Windows Phone 7
PPTX
Generating characterization tests for legacy code
PPTX
Get a flying start with Windows Phone 7 - NDC2010
PPTX
Smidig brukeropplevelse med skjermbildeprototyper (Smidig2009)
PPTX
MVVM Design Pattern NDC2009
PPT
Silverlight 2 for Developers - TechEd New Zealand 2008
Introduction to F#
Hvordan lage en vellykket Windows Phone 7 App
Hvordan lage en vellykket WP7 applikasjon
Why learn new programming languages
Smidig 2011 TDD Workshop
An overview of the Windows Phone 7 platform
Windows Phone 7 lyntale fra Grensesnittet Desember 2010
NNUG Trondheim 30.09.2010 - Windows Phone 7
Generating characterization tests for legacy code
Get a flying start with Windows Phone 7 - NDC2010
Smidig brukeropplevelse med skjermbildeprototyper (Smidig2009)
MVVM Design Pattern NDC2009
Silverlight 2 for Developers - TechEd New Zealand 2008

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Electronic commerce courselecture one. Pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Reach Out and Touch Someone: Haptics and Empathic Computing
Electronic commerce courselecture one. Pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Advanced Soft Computing BINUS July 2025.pdf
NewMind AI Weekly Chronicles - August'25 Week I
The Rise and Fall of 3GPP – Time for a Sabbatical?
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
MYSQL Presentation for SQL database connectivity
Telecom Fraud Prevention Guide | Hyperlink InfoSystem

Cross platform mobile apps using .NET