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

What's hot (20)

PPTX
Node.js kubernetes-cloud all the buzzwords coming together with microsoft azure
Patriek van Dorp
 
PPTX
Blazor and Azure Functions - a serverless approach
Alex Pshul
 
PPTX
Athena, Android UI Testing Platfrom
Buddy Arifin
 
PPTX
Seattle Code Camp 2016 - .Net Core
Amol Gholap
 
PDF
Bridge the Dev/Production Gap with Docker
John Oerter
 
PDF
"Building a Production-Grade Serverless Deployment" - Eoin Shanaghy, CTO, fo...
LCloud
 
PDF
DevOps Days Kyiv 2019 -- What you see is what you get for AWS // Anton Babenko
Mykola Marzhan
 
PDF
OpenShift: Java EE in the clouds
Max Andersen
 
PPTX
Azure Fast 7 - The Fastest & Easiest way to get your Web apps onto Azure
Micheal Colhoun
 
PDF
Play on Docker
Daniel Pfeiffer
 
PDF
Aegir Fresno Drupal User Group 1-21-10
Bob Kepford
 
PDF
Appenginejs (old presentation)
Panagiotis Astithas
 
PDF
Deploy Angular to the Cloud (ngBucharest)
Simona Cotin
 
PDF
Kubernetes and the 12 factor cloud apps
Ana-Maria Mihalceanu
 
PDF
Was is Docker? Or: Docker for Software Developers
Christian Nagel
 
PDF
Fastlane - Automation and Continuous Delivery for iOS Apps
Sarath C
 
PPTX
Ultimate Productivity Tools
Amal Dev
 
PDF
Docker Tooling for Eclipse
Max Andersen
 
PDF
Advanced front-end automation with npm scripts
k88hudson
 
PPTX
15-ways-to-optimize-spring-boot-for-the-cloud
Billy Korando
 
Node.js kubernetes-cloud all the buzzwords coming together with microsoft azure
Patriek van Dorp
 
Blazor and Azure Functions - a serverless approach
Alex Pshul
 
Athena, Android UI Testing Platfrom
Buddy Arifin
 
Seattle Code Camp 2016 - .Net Core
Amol Gholap
 
Bridge the Dev/Production Gap with Docker
John Oerter
 
"Building a Production-Grade Serverless Deployment" - Eoin Shanaghy, CTO, fo...
LCloud
 
DevOps Days Kyiv 2019 -- What you see is what you get for AWS // Anton Babenko
Mykola Marzhan
 
OpenShift: Java EE in the clouds
Max Andersen
 
Azure Fast 7 - The Fastest & Easiest way to get your Web apps onto Azure
Micheal Colhoun
 
Play on Docker
Daniel Pfeiffer
 
Aegir Fresno Drupal User Group 1-21-10
Bob Kepford
 
Appenginejs (old presentation)
Panagiotis Astithas
 
Deploy Angular to the Cloud (ngBucharest)
Simona Cotin
 
Kubernetes and the 12 factor cloud apps
Ana-Maria Mihalceanu
 
Was is Docker? Or: Docker for Software Developers
Christian Nagel
 
Fastlane - Automation and Continuous Delivery for iOS Apps
Sarath C
 
Ultimate Productivity Tools
Amal Dev
 
Docker Tooling for Eclipse
Max Andersen
 
Advanced front-end automation with npm scripts
k88hudson
 
15-ways-to-optimize-spring-boot-for-the-cloud
Billy Korando
 

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

PDF
Sharing up to 80% code for iOS, Android, and Windows platforms, a Retail App ...
Xamarin
 
PDF
Three's Company - Writing for the Desktop, Browser, and Phone
Sarah Dutkiewicz
 
PPTX
Cross platform mobile app development with Xamarin
Pranav Ainavolu
 
KEY
Cross Platform Development with Xamarin
bryan costanich
 
PPT
Cross-Platform Mobile Development in Visual Studio
bryan costanich
 
PPTX
App innovationcircles xamarin
Mohit Chhabra
 
PPTX
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Rainer Stropek
 
PPTX
Dia 1 intro to mobile and xamarin
Hernan Zaldivar
 
PPTX
Shape 2013 developing multi targeting windows store and windows phone apps
Jose Luis Latorre Millas
 
PPTX
Introduction to MonoTouch
Jonas Follesø
 
PDF
Introduction to MonoTouch and Monodroid/Mono for Android
Chris Hardy
 
PPTX
Introduction to Xamarin Mobile Platform
Dominik Minta
 
PPTX
Iasi code camp 12 october 2013 adrian marinica - windows 8 and windows phon...
Codecamp Romania
 
PPTX
Develop business apps cross-platform development using visual studio with x...
Alexander Meijers
 
PDF
Portable Class Libraries and MVVM
Andreas Kuntner
 
PPTX
MonoTouch 5.2 Introduction
Xamarin
 
PPTX
Eco system apps
Sergey Seletsky
 
PDF
MvvmCross Seminar
Xamarin
 
PDF
MvvmCross Introduction
Stuart Lodge
 
PPTX
C# everywhere: Xamarin and cross platform development
Gill Cleeren
 
Sharing up to 80% code for iOS, Android, and Windows platforms, a Retail App ...
Xamarin
 
Three's Company - Writing for the Desktop, Browser, and Phone
Sarah Dutkiewicz
 
Cross platform mobile app development with Xamarin
Pranav Ainavolu
 
Cross Platform Development with Xamarin
bryan costanich
 
Cross-Platform Mobile Development in Visual Studio
bryan costanich
 
App innovationcircles xamarin
Mohit Chhabra
 
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Rainer Stropek
 
Dia 1 intro to mobile and xamarin
Hernan Zaldivar
 
Shape 2013 developing multi targeting windows store and windows phone apps
Jose Luis Latorre Millas
 
Introduction to MonoTouch
Jonas Follesø
 
Introduction to MonoTouch and Monodroid/Mono for Android
Chris Hardy
 
Introduction to Xamarin Mobile Platform
Dominik Minta
 
Iasi code camp 12 october 2013 adrian marinica - windows 8 and windows phon...
Codecamp Romania
 
Develop business apps cross-platform development using visual studio with x...
Alexander Meijers
 
Portable Class Libraries and MVVM
Andreas Kuntner
 
MonoTouch 5.2 Introduction
Xamarin
 
Eco system apps
Sergey Seletsky
 
MvvmCross Seminar
Xamarin
 
MvvmCross Introduction
Stuart Lodge
 
C# everywhere: Xamarin and cross platform development
Gill Cleeren
 
Ad

More from Jonas Follesø (13)

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

Recently uploaded (20)

PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
PDF
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
July Patch Tuesday
Ivanti
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 

Cross platform mobile apps using .NET