Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Native, Cross platform, Mobile - Codemania 2014

Native, Cross platform, Mobile - Codemania 2014

My Codemania talk from April 2014. Code for it is here: https://github.com/nicwise/codemania2014.

Nic Wise

April 04, 2014
Tweet

More Decks by Nic Wise

Other Decks in Programming

Transcript

  1. 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.
  2. “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
  3. 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
  4. 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.
  5. 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
  6. 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.
  7. 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/
  8. • 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/
  9. • 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
  10. • 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/
  11. • 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
  12. • 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
  13. 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
  14. PropertyCross A single project, reimplemented in 16 cross platform tools.!

    All source available! ! http://propertycross.com
  15. 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
  16. 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
  17. Networking • HttpClient • ModernHttpClient - uses the platform-specific clients

    under the hood • RestSharp, ServiceStack • Native/3rd party on both platforms (eg NSUrlSession, AFNetworking, OkHttp)
  18. MVxx • MVVM, MVP, MVC, MVAB • MVVMCross, the 800lb

    Gorilla • ReactiveUI • Lots of others around, a few “being worked on” ! • Or just roll your own