Slide 1

Slide 1 text

Greg Shackles Cross-platform mobile development with c#

Slide 2

Slide 2 text

About Me Greg Shackles Senior Software Engineer OLO Online Ordering email [email protected] twitter @gshackles github github.com/gshackles blog gregshackles.com Slides speakerdeck.com/u/gshackles

Slide 3

Slide 3 text

nycmobiledev.net @NYCMobileDev

Slide 4

Slide 4 text

the Book oreil.ly/Lp5smR Discount Code: AUTHD Print Book: 40% Off E-Book: 50% Off

Slide 5

Slide 5 text

Market Share (US): August 2012 Google Apple RIM Microsoft Symbian 52.6% Android 34.3% Apple 8.3% RIM 3.6% Microsoft Source: comScore

Slide 6

Slide 6 text

native platform Languages Objective-C Java C#

Slide 7

Slide 7 text

Write once, run anywhere

Slide 8

Slide 8 text

"The biggest mistake we made as a company was betting too much on HTML5 instead of native." - Mark Zuckerberg

Slide 9

Slide 9 text

Embrace the differences != !=

Slide 10

Slide 10 text

c# Everywhere MonoTouch Mono for Android Native

Slide 11

Slide 11 text

The Power of C# •Base Class Library •LINQ •Parallel LINQ •Memory Management •Task Parallel Library •Dynamic •Skill Reuse

Slide 12

Slide 12 text

xamarin Tools •Access to full platform SDKs •100% Native •Linker •Debugging •frequent releases •active community •Improved API

Slide 13

Slide 13 text

C# CFStringRef  keys[]  =  {        kCTFontAttributeName,        kCTForegroundColorAttributeName };   CFTypeRef  bval[]  =  {        cfListLineCTFontRef,        CGColorGetConstantColor(kCGColorBlack) };   attr  =  CFDictionaryCreate  (        kCFAllocatorDefault,        (const  void  **)  &keys,  (const  void  **)  &bval,        sizeof(keys)  /  sizeof(keys[0]),  &kCFTypeDictionaryKeyCallBacks,        &kCFTypeDictionaryValueCallBacks);   astr  =  CFAttributedStringCreate( kCFAllocatorDefault,  CFSTR("Hello  World"),  attr); obj-c var  attr  =  new  CFStringAttributes  {        Font  =  listLineCTFont,        ForegroundColor  =  UIColor.Black.CGColor };   var  astr  =  new  NSAttributedString  ("Hello  World",  attrs);

Slide 14

Slide 14 text

C#             findViewById(R.id.button).setOnClickListener( new  View.OnClickListener()          {              @Override      public  void  onClick(View  v)      {              //  handle  click      }        } ); Java [Activity(Label="@string/AppName",  MainLauncher=true)] FindViewById(Resource.Id.Button).Click  +=  delegate   {   //  handle  click };

Slide 15

Slide 15 text

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UI and Platform Code Shared Code

Slide 16

Slide 16 text

What code can be shared? * with some limitations •Most non-UI or platform code •Core application logic •Entities •LINQ (objects, XML) •Network access •File / Database Access *

Slide 17

Slide 17 text

sharing techniques •File Linking •Abstraction •Observer Pattern •Partial Classes and Methods •Conditional Compilation •portable class libraries

Slide 18

Slide 18 text

library: xamarin.mobile Supports iOS, Android and Windows Phone xamarin.com/mobileapi

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

Case Study: iCircuit

Slide 21

Slide 21 text

http://praeclarum.org/post/31799384896/icircuit-code-reuse-the-fourth-edition 16% 84% Shared Platform 31% 69% 13% 87% iOS WP7 Mac 19% 81% Android Case Study: iCircuit

Slide 22

Slide 22 text

Case Study: TouchDraw

Slide 23

Slide 23 text

http://lipsky.me/2012/9/11/touchdraw-code-reuse-updated 39% 61% Shared Platform 24% 76% 28% 72% iOS Mac Android Case Study: TouchDraw

Slide 24

Slide 24 text

SignalR Client Libraries http://github.com/gshackles/SignalR C# To Go Mono.CSharp http://github.com/gshackles/CSharpToGo Case Study: Class Libraries

Slide 25

Slide 25 text

Questions?