2016-07-19

Xamarin

As a Microsoft Gold Partner, Soho Dragon Solutions loves to highlight Microsoft products/services that we feel are cutting edge, innovative, and state of the arch- just like us. Although we are most notable for our SharePoint expertise, we also provide services in BI, Staff Augmentation, and other hosted solutions. We like to think we are pioneers in the digital workspace!

Xamarin – What is it?

Xamarin is a product now owned by Microsoft.  The product was developed by engineers who created MonoMono for Android and MonoTouch that are cross-platform implementations of the Common Language Infrastructure (CLI) and Common Language Specifications (often called Microsoft.NET).

With a C#-shared codebase, .Net developers can use Xamarin tools to write native Android, iOS, and Windows apps with native user interfaces and share code across multiple platforms all from Visual Studio.

Xamarin Evolve 2016: Keynote

So, what does this mean? The Visual Studio developers can now develop smart phone apps… Oh Yeah. The skinny

Xamarin has three basic sets of .NET libraries:

i.      Xamarin.Mac, which has evolved from the MonoMac project.

ii.      Xamarin.iOS, which evolved from MonoTouch.

iii.     Xamarin.Android, which evolved from Mono for Android or (more informally) MonoDroid.

Together these libraries are known as the Xamarin platform and consist of .NET versions of the native Mac, IOS, and Android APIs, any geek using these libraries can write applications in C# and to target the native APIs of these three platforms with a code once, deploy anywhere approach.

But wait there’s more.   There’s access to the .NET Framework class library.

Use modern C# language to write code that can work cross platform:

iv. For iOS, C# is ahead of time compiled to ARM assembly language.

v. For Android, C# is compiled to IL and packaged with MonoVM + JIT’ing

vi. For Windows, C# is compiled to IL and executed by the built-in runtime and does not require Xamarin.

References for more detailed introduction to go Cross Platform with Xamarin

https://channel9.msdn.com/Events/Build/2016/B836

https://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Cross-Platform-Development-With-Xamarin

And why should a Visual Studio Developer care?

1. Often mobile app development involves a steep learning curve for a Visual Studio developer like learn programming languages such as Java for Android and Objective C or Swift for iOS, platform SDKs like Android SDK and iOS SDK, and IDEs like Android Studio and Xcode and also Mac OS if you developing for iOS.

i. If you know .Net/C# which is common amongst Visual Studio developers, then you can straight away start developing mobile apps writing code in C#.

ii. As now Microsoft owns Xamarin, so it is available for every visual studio edition including the community edition which is free for individual developers, education and research. So visual studio developers feel at home to develop cross platform mobile apps using Xamarin. Developers don’t need to learn new IDE in order to develop mobile apps.

How easy is it to learn?

C# and .NET developers will be amazed due to following reasons, on how easy it is to develop cross platform mobile apps.

i. .NET developers get the opportunity to reach, beside Windows, the major mobile platforms: iOS and Android.

ii. They don’t have to learn the new programming language and a new IDE

iii. Write less code as backend of the code can be shared across platforms

iv. Use the Windows APIs such as System.Net, System.IO, System.Linq, System.Xml, System.Data and more which C# .Net developers would have been using since long in their .Net applications

If you are not a .net developer, then also you will spend less time in learning, as compared to learning different SDKs and programming languages Java for Android and Swift or Objective C for iOS. For Xamarin you will be required to learn only C# and common SDK and standard .Net classes across all three platforms.

1. Use MVC (Model View Controller) or MVVM (Model View ViewModel) design pattern, to develop your application’s User Interface which is widely used across all programming languages which separates your backend and business logic code from UI code.

2. Share your code across three platforms, so you have to write unit tests only once, fix non UI bugs on three platforms at once, reuse code from your old desktop apps or websites. So in summary there is less code to maintain, that reduces time, effort and cost.

Links: Xamarin for Absolute Beginners

What’s tricky about it?

Xamarin has an operational overhead as app size can grow proportionally as code uses more and more APIs. This is due to way .Net assemblies are linked as native code, into apps. This affects the download time, startup time of the app and amount of storage space that app uses on your devices. So keep a watch on the APIs you keeping adding to project which will increase the size of app, example below:

I wrote a sample app to get check the connectivity of phone to internet and if its connected to internet then app displays the public IP to the user. So this app did not have code more than 100 lines, and it used few libraries such as HTTPClient, Xamarin Forms and HTMLPack, though the app size was around 26 MB for Android. That’s quite large for a tiny sample app. Though there are some work arounds to reduce the size of app which may help to reduce the app size.

References:

https://gist.github.com/jgold6/a1e60e0bb24ccdd2b2b8

https://developer.xamarin.com/guides/android/advanced_topics/application_package_sizes/

http://motzcod.es/post/112072508362/how-to-keep-your-android-app-size-down

1. Shared code can also be written for UI using Xamarin forms, but this has limited controls, so if you want write an app with much customized UI, then in the end you will end writing platform specific code, so most of the UI code will still be platform specific, examples below:

2. We wanted to make a horizontal tiled UI in Xamarin forms app with which we could use Data Binding and MVVM, but there aren’t any controls available in Xamarin Forms to do that kind of UI. We had developed horizontal Tiled UI in Windows Universal Apps(UWP) using a GridView control which is not available in Xamarin Forms. Xamarin Forms only has ListView control in which items can go vertical and it’s like a list not tiles.

3. We wanted custom interactive popups, with our data and inputs and buttons from which user can edit and save data, but those popup controls are not available in Xamarin Forms. Xamarin Forms only has alert functionality for popup with which we can show informational messages to users. So we in order to implement custom interactive popups, we ended up writing platform specific code for Android, iOS and UWP.

The Good

1. Less maintenance of code due to shared code, hence fewer bugs.

2. Robust C# language, allows you to use a familiar syntax and sophisticated features like Generics, Linq and async/await/Task.

3. Faster time to market as compared to developing native apps for each platform. For Xamarin at least backend and application logic code can be shared.

4. Substantially less learning curve for companies who work mainly on .net platform.

5. Though the code you write is not native, user experience that Xamarin provides is native, so it provides platform specific look and feel that Android and iOS users are accustomed to.

6. Large community support as Microsoft owns Xamarin, future support will also be good.

7. Test your apps using Xamarin Test Cloud which provides an automative way of UI Acceptance Testing of mobile applications in cloud across hundred different devices.

The Bad

1. UI code is still not shared though it provides Xamarin Forms framework which allows us to write shared UI code, is not robust to allow us to write attractive common UI code. Furthermore, Xamarin forms is a package that runs on top of Xamarin platform, so it will affect the performance of app if app is huge.

2. If you are certain to develop mobile app for one specific platform, then native app development will be a better option.

3. You still require MAC to compile the apps for iOS.

The Ugly

1. Size of app increase as you keep on adding more and more APIs to the code.

2. There is overhead on the download time and startup time of the app, due to the way linking of codes between .net framework and target application platform.

3. Does not support sharing of code outside .Net environment e.g. Xamarin code cannot be used for native HTML 5 apps.

Soho’s Recommendations:

The Dragon Developers’ do not recommend using Xamarin for customer facing application as it will require attractive and robust UI, using Xamarin here will not be helpful as you will end up writing platform specific code. We recommend Xamarin to be used to develop cross platform line of business enterprise apps where there is significant business logic.

Want to decide whether or not to use Xamarin Forms then refer this: http://cdn1.xamarin.com/Architecture%20Selector.pdf

Media Contact
Company Name: Soho Dragon
Contact Person: Peter Ward
Email: Send Email
Phone: (862) 220-6080
Country: United States
Website: http://www.sohodragon.nyc/

Show more