Xamarin!

In his book “Xamarin Essential” Mark Reynolds starts with this question: “Do you remember when, in Star Wars, Anakin realizes that Palpatine knows the dark side of the strength?

09 giu 2015

What is it?

 

In his book  “Xamarin Essential” Mark Reynolds starts with this question: “Do you remember when, in Star Wars, Anakin realizes that Palpatine knows the dark side of the strength?

 

If you replace the dark side of strength with Xamarin, the sentence would be more or less as follows: “Xamarin is the way to gain more skills, that someone unfairly consider as unnatural”.

 

The first time you use it, your feeling will be just this one, how can you write code C# running on iOS and Android?

 

Xamarin is a framework based on C#, designed to allow the development of multi- platform mobile applications. It was created by Miguel De Icaza in2011 and strongly relies on Mono project.

 

Why?

 

The development of mobile applications is expensive in terms of resources and knowledge… as well as being, unfortunately, still not considered at a business level in Italy.

 

The classic approach (Silo) is to create different development teams, one per platform.

 

To remedy the duplication of work implied by this method, different development frameworks have been created. Hybrid frameworks (Black Box) allows to create apps similar to the web ones, developed in HTML, CSS and JavaScript, then executed on a browser.

 

This solution has the disadvantage of limiting the specific functions on each system, creating user interfaces that look the same each other, thus limiting the experience of those users who expect instead a look and feel closer to their platform.

 

However, the possibility to use a tool that provides a development paradigm known and common to the three systems is a good reason that urges companies and development teams to follow this path. This solution has the advantage of not having to know the development API of different operating systems, thus it is often applied for lack of resources and time.

 

Xamarin.Droid and Xamarin.iOS

 

In this context, Xamarin offers similar advantages, allowing the use of C# language and .NET for the development of Android, iOS and Windows Phone applications, with the further possibility to use native characteristics, both for the interface and the typical characteristics, of the different platforms. It is versatile and fully integrated in Visual Studio.

 

Xamarin wraps native API of each platform with a wrapper C#, allowing the developer to interact with the operating system in a transparent way and like an Android or iOS developer does.

 

Applications are compiled separately, in native code, during the deploy.

 

The use of Xamarin.iOS and Xamarin.Android allows to share (with clear benefits for future developments and maintainability) about 60% of the code among the different applications. However, you should know the development patterns on which iOS and Android are based and the typical characteristics of the two operating systems.

 

The UI remains a critical layer where to act upon.

 

 

Xamarin Forms

 

In 2014, Charles Petzold, employee and developer at Xamarin, had the brilliant idea to create Xamarin.Forms. The idea is quite simple: you need a common framework that allows to create the UI of the applications, regardless of the platform. Having C# and the huge side infrastructure, why not using XAML and MVVM?

 

Xamarin.Forms adopts these concepts together with that of Portable Class Library (PCL).

 

A PCL is a compiled portable library to run of a subset of .NET compatible with different platforms.

 

Developing an app in Xamarin.Forms is very similar to WPF with the advantage of fully disregarding the platform, its patterns and its operating system.

 

 

Our first experience

 

Last month, we developed two applications using Xamarin.Forms for some historic customers of Elfo. The experience and the feedbacks were positive of course.

 

Xamarin.Forms was created a few months ago, therefore it should be improved under some aspects (available checks firstly) but its potential is very high considering the strong partnership between Xamarin and Microsoft and the decision to publish the source code of a big part of .NET by the latter.

 

Last but not least is the strong contribution of the community that is rooted on WPF.

 

Xamarin.Forms is not suitable for all apps. Applications needing strong customizations at the interface level or have to exploit more the hardware, native choice using Xamarin.iOS and Xamarin.Android is recommended. On the contrary, it is the best solution for “data centric” applications that have to handle and display data with intuitive and simple interfaces, typical in mobile devices.

 

Another important aspect regards the tests on the application maintainability. Through Xamarin Test Cloud, you can test apps on thousands of devices without having them and you can interact like a real user.

 

Xamarin Insights allows to monitor the app in a detailed and fast way, providing statistical data used to understand how the user uses the application and acting soon in case of problems.

 

What to say…thumbs on Xamarin!