Four Platforms, One Codebase
Upcoming SlideShare
Loading in...5

Four Platforms, One Codebase



You want to write mobile apps, but you don’t want to write the same code four times over. You want cross-platform apps, but you don’t want to sacrifice the native speed and power. You want to ...

You want to write mobile apps, but you don’t want to write the same code four times over. You want cross-platform apps, but you don’t want to sacrifice the native speed and power. You want to create native iOS, Android, Windows Phone, and Windows 8 apps, and you want it all while maximizing code reuse and harnessing the power and simplicity of C#. You want four native platforms, but you want one codebase.
Of course you do. You want Xamarin.



Total Views
Views on SlideShare
Embed Views



2 Embeds 10 7 3



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment
  • &lt;Intro&gt; <br /> I think C# is a beautiful language, and I’m amazed at how it has grown and evolved over the years, taking us places we never thought about before. <br />
  • Tonight, I’m going demonstrate what I find to be the most exciting place to find C#; on our mobile devices. ALL of our mobile devices. I assume everyone here has a mobile device. How many have an iOS device? (iPhone/iPad)? Android phone or tablet? Windows Phone or Windows RT tablet? Windows 8? Mac Desktop? All of these platforms and devices are candidates to be running C# thanks to Xamarin. <br />
  • Ask: How much does the typical mobile app cost to create? $1000? $2000? $5000? (Wait for answers) <br />
  • According to a recent study, 80% of apps cost over $25,000 to create. Over HALF of all apps cost more than $50,000 to create. And that is per app. But, as we all know, it&apos;s a fragmented market out there.  <br /> Android accounts for 52% of devices, iOS brings in another 40%, and &quot;Other&quot;, including Windows Phone makes up the other 8%.  But even these numbers are fragmented. There are five major versions of Android in the wild at the moment. iOS has three major versions out now. There are six different iOS screen resolutions, and an infinite number of Android resolutions. Windows Phone is coming out with newer, bigger phones soon, and Windows 8 apps can be any size at all.  When each app costs $25,000-$100,000 to create, the cost of designing and developing for each platform individually can skyrocket out of control. You’re left with a difficult decision…target one or two major platforms and leave a significant percentage of potential customers out in the cold, incur the cost to create an app for every platform, or find another way. <br /> Source : AnyPresence Mobile Readiness Report 2013 <br />
  • Let’s talk about the state of mobile development today <br />
  • Expensive & Slow <br /> Positive = Great apps delivered to user’s platform <br /> Negative = Development hampered by multiple code bases & fragmentation <br />
  • Unhappy users <br /> Unhappy developers <br /> Increase in abandoned apps <br /> Limited to what is implemented <br />
  • four years old <br />
  • The #1 benefit is that we get to share our code between platforms. And not just a little bit. There are multiple case studies showing it’s easy to get 70%-90% code reuse between platforms. This dramatically cuts down on costs as well as bugs. <br /> Second, as .net developers, we get to use our existing .net skills. As a business that already has .net developers and is getting started building our first mobile apps, we can either pay for an Objective-C developer, a Java developer, and our existing .net developers, or we can have that same .net dev, with their accumulated business domain knowledge working across all platforms. <br /> Third, since Xamarin is based on mono and C#, we get a modern programming language. This means that we get async/await, linq, generics, lambdas, nuget, and packages such as, restsharp, mvvmcross, and more. <br /> Fourth, we get powerful IDE support. With Xamarin we can choose between Xamarin Studio, a rich IDE which runs natively on Mac and Windows, or we can use Visual Studio, one of the most popular and powerful IDEs on the planet. This allows us to have a single, familiar IDE to develop in and share code between our iOS, Android, Windows Phone, Windows Store apps. <br /> Lastly, with Xamarin, we get extensive support and documentation. <br /> An important distinction between Xamarin and other frameworks is that Xamarin is completely, 100% native. The C# code that we write ultimately compiles down to native binaries on the target platforms. Unlike other systems such as PhoneGap or Titanium, with Xamarin we get full access to the underlying OS. Anything that Objective-C or Java can do, Xamarin can do. You are not limited in any way. Xamarin’s approach also brings with it the native UI toolkits for each platform. Xamarin does not abstract the user interface away, leaving you with the lowest common denominator for user interfaces. Each UI will still be custom developed and perfected for each platform, ensuring that your apps are beautiful, fast, and native. <br />
  • Let’s talk a bit about C# and why it is awesome. <br />
  • Objective-C to get the date from a date time variable <br />
  • C# to get the date from a date time variable <br />
  • Objective-C to trim spaces from a string <br />
  • C# to trim spaces from a string <br />
  • Objective-C to find a contact in address book <br />
  • Java to find a contact in address book <br />
  • C# to find a contact in address book <br />
  • Let&apos;s take a step back, and talk about Mvvm <br />
  • Mvvm is a GUI design pattern which originated at Microsoft in 2005, when they were first designing WPF and, later, Silverlight. According to John Gossman, one of the main designers of Mvvm, &quot;Model/View/ViewModel is a variation of Model/View/Controller (MVC) that is tailored for modern UI development platforms where the View is the responsibility of a designer rather than a classic developer.&quot; Mvvm is all about binding. We can easily bind properties, collections, and actions (or commands). This declarative binding allows us to easily separate the presentation (the view) from the behavior. <br />
  • In Mvvm, the view is only concerned with the presentation of elements on the screen. The model, as in MVC, could also be called the data model. It represents the intrinsic shape of the data. The ViewModel sits in between the view and the model. It handles loading content the UI needs,hiding and showing content, Date/number/string formatting, responding to the user, performing commands, saving and retrieving data. <br />
  • This separation of the View from the behavior, via data binding is perfect for our cross platform world. This allows us to reuse the logic in our view models, while continuing to have completely native UIs for iPhone, iPad, Android phones, Android tables, WPF, WinRT, Silverlight, Mac desktop, and Windows Phone devices. This also allows us to have designers work on making the iOS and Android UIs pretty, while allowing developers to create the Windows Phone and Windows 8 UIs. <br />
  • So, given the theory behind Mvvm, how does MvvmCross help us? <br /> MvvmCross is an open source cross platform Mvvm framework written by Stuart Lodge. It&apos;s currently on its third version, and has a very active and healthy community around it. <br />
  • The beauty of MvvmCross is that it supports iOS, Android, Windows Phone 7, Windows Phone 8, Mac Desktop, WPF, Silverlight, Windows 8/RT, and Powershell. This allows us to write the core logic of our app, and reuse it completely across eleven platforms. I&apos;ll be demonstrating iPhone, Windows Phone, Windows 8, and Android today. MvvmCross focuses on shared behavior, not presentation. Mvvm itself was introduced with WPF, but then left to stagnate by Microsoft. There haven&apos;t been any meaningful updates to the XAML syntax since WPF was first released.  <br />
  • MvvmCross adds powerful binding options to XAML, as well as introducing binding to iOS and Android platforms. Here we see an example of binding a property in our ViewModel it each View. <br />
  • MvvmCross includes a pluggable architecture, and comes with an IOC container which runs on all platforms. Due the extensibility and pluggable architecture, there are plugins on nuget for json, working with local files, sqlite, message bus, location (gps), web browser, network utilities, email, and many more. <br />

Four Platforms, One Codebase Four Platforms, One Codebase Presentation Transcript

  • Four Platforms, One Codebase Cross Platform Mobile Apps with Xamarin rob gibbens interactive business systems
  • what does an app cost?
  • mobile development approaches View slide
  • silos • • • • build app multiple times multiple teams multiple code bases different toolsets View slide
  • write once, run anywhere • • • lowest common denominator browser fragmentation developing and designing for one platform
  • xamarin‘s unique approach • • • • • native user interface native performance shared code across platforms c# and .net framework full api coverage
  • why C#?
  • C# is awesome • • • • • async/await linq xml + xdocument event handling, delgates, lambdas generics
  • + (NSDate *) stripTime:(NSDate *) date { NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *components = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:date]; date = [gregorian dateFromComponents:components]; [gregorian release]; } return date;
  • var newDate = date.Date;
  • NSString *string = @“ spaces in front and at the end “; NSString *trimmedString = [string stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
  • var trimmedString = “ spaces in front and at the end “.Trim();
  • mvvm
  • mvvmCross
  • json serializer visibility message bus download cache file system phone call gps photos sqlite web browser email accelerometer network localization
  • let’s code!
  • Contact Rob Gibbens github: twitter: @RobGibbens email :