Slide 1

Slide 1 text

Native, Cross-platform, Mobile Nic Wise! @fastchicken

Slide 2

Slide 2 text

Why Cross-platform?

Slide 3

Slide 3 text

See, WhatsApp wasn't born in Silicon Valley on an iPhone, rather it fought its way to a $16B exit by providing an awesome messaging experience to the middle billion, those living on $10 a day. And you know what, on $10 a day you probably don't have an iPhone or an Android handset. Rather you are probably carrying around a "feature phone", one of a thousands variations of handsets built by Nokia or Samsung running a version of Java 2 Mobile Edition. — TextIt.In Blog - http://blog.textit.in/your-path-to-a-$16b-exit-build-a-j2me-app This might be going too far. But one platform is no longer going to cut it.

Slide 4

Slide 4 text

The Three Ways

Slide 5

Slide 5 text

“The client-side mess · Things are bad. You have to build everything three times: Web, iOS, Android. We’re talent-starved, this is egregious waste, and it’s really hurting us.” — Tim Bray http://www.tbray.org/ongoing/When/201x/2014/01/01/ Software-in-2014

Slide 6

Slide 6 text

HTML5 • “Write once, run anywhere” • Apache Cordova, Phonegap as containers • Topcoat; jQTouch; KendoUI; PhoneJS; Sencha Touch 2; others • Wrapper around a native browser (but without JIT’ed Javascript on iOS) • But the browsers aren’t the same! • Easy to make an app. A lot harder to make something which looks right on each platform

Slide 7

Slide 7 text

Know Your Mobile - Best and Worst of UK Banking Apps! http://www.knowyourmobile.com/mobile-phones/banking-apps/21804/best-and-worst-uk-banking-apps … Lloyds—the bank that set the standard for the worst banking app you can create. Sadly for Halifax users, the app is a rebranded version of the Lloyds app, which means it’s nothing more than a mobile website disguised as an app.

Slide 8

Slide 8 text

Code it twice • Write the whole thing twice - once in Objective C, once in Java • Or three times • Separate teams or one team doing both feature-by-feature • Works, but a lot of reworking and context- switching tax

Slide 9

Slide 9 text

Cross-platform Native • Ideal Goal • One language/library like HTML5 • Works on all platforms from one code base, but uses the native controls/libraries This is a pipe dream and will never happen.

Slide 10

Slide 10 text

There is no “Write once…”. I wish there were. I know you wish there were too. But I wish my daughter had a baby unicorn to ride too. There is, however, “Focus on creating the best possible user experience on each device and try to get as much code re-use as you can along the way.” ! — Charlie Kindle http://ceklog.kindel.com/2013/02/21/james-gosling- screwed-us-write-once-is-anti-customer/

Slide 11

Slide 11 text

• Delphi (Object Pascal++) and C++ • Abstracts the UI, using a similar method to SWING • Common cross platform base library • iOS, Android, Windows, Mac • http://www.appmethod.com/

Slide 12

Slide 12 text

• Pascal / C#, with a lot of modern additions • Compiles down to the native platform, but no common library (yet) • iOS, Android, Windows, Mac • Needs both Windows (VS) and Mac (toolchain) for iOS development • http://www.remobjects.com/elements/oxygene/ • http://www.remobjects.com/cs

Slide 13

Slide 13 text

• C#/F#/VB.NET + .NET FX • Full access to the native platform (including ObjC classes and Android JARs) • Share common, platform independent code; use common platform-independent libraries • Write platform dependant (usually UI) code N times. • iOS, Android, WinPhone, Win8, Mac, others. • http://xamarin.com/

Slide 14

Slide 14 text

• Based on Mono, open source (LGPL and commercial) .NET runtime • Write code in Xamarin Studio or Visual Studio • Do some bits in Xcode (XIB editor, storyboards, archive to AppStore) • iOS: Runs as native ARM code. No JIT, no interpreter. • Android: Mono VM runs as a peer to Dalvik. Can JIT, can do lots more than iOS

Slide 15

Slide 15 text

• Think of the iOS stack, but replace ObjC with C# • Think of the Android stack, but replace Java with C# • Add the rest of the .NET framework

Slide 16

Slide 16 text

Native UI. Native Performance. 
 Shared code across platforms.! Full API coverage! C# at every level

Slide 17

Slide 17 text

Q: “So, just how much can we reuse?” A: “It depends….”

Slide 18

Slide 18 text

iCircuit: 70-90% source: Frank Krueger - http://praeclarum.org/

Slide 19

Slide 19 text

Calca: about 75-95% “This is the general lesson I’ve learned over the years: writing iOS apps is a hell of a lot more work than writing Mac apps. Enlightening? No. Honest? Yeah.” ! - Frank Krueger! http://praeclarum.org/post/55529252776/calca-os-x-now- available-code-reuse

Slide 20

Slide 20 text

PropertyCross A single project, reimplemented in 16 cross platform tools.! All source available! ! http://propertycross.com

Slide 21

Slide 21 text

Strategies

Slide 22

Slide 22 text

The Usual Suspects • Inversion of Control, Dependancy Injection • TinyIOC, Ninject • Messaging • TinyMessenger, ReactiveUI* • Separation of concerns, layering • Test Drive Development • NUnitLite built in, or treat desktop unit tests as a separate platform

Slide 23

Slide 23 text

Databases • SQLite - everyone’s favourite small database. • SQLite-Net PCL on NuGet • Mono.Data.SqliteClient ADO.NET provider • Zumero - SQLite replication from SQL Server ! • Akavache - Async Key-Value Store • Couchbase for .NET - NoSQL, syncs to server-side

Slide 24

Slide 24 text

Networking • HttpClient • ModernHttpClient - uses the platform-specific clients under the hood • RestSharp, ServiceStack • Native/3rd party on both platforms (eg NSUrlSession, AFNetworking, OkHttp)

Slide 25

Slide 25 text

MVxx • MVVM, MVP, MVC, MVAB • MVVMCross, the 800lb Gorilla • ReactiveUI • Lots of others around, a few “being worked on” ! • Or just roll your own

Slide 26

Slide 26 text

@paulcbetts @slodge Cross-platform Superstars

Slide 27

Slide 27 text

Quick Currency

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Summary

Slide 30

Slide 30 text

Thanks! @fastchicken [email protected] https://github.com/nicwise/codemania2014