Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Should App Developers Go for Xamarin?

DZone's Guide to

Should App Developers Go for Xamarin?

Building a cross platform mobile app remains challenging because programming language, event model, UI model, and resource model all differ from one platform to other. Xamarin can help with this.

· Mobile Zone
Free Resource

Launching an app doesn’t need to be daunting. Whether you’re just getting started or need a refresher on mobile app testing best practices, this guide is your resource! Brought to you in partnership with Perfecto

Image title

Be it a company or an entrepreneur, if an app needs to be developed for them, it cannot be just on one platform. The current mobile ecosystem works basically on 3 main platforms – Android, iOS, and Windows. For every new client the apps based on these 3 platforms need to be in stores, ready for downloads, as soon as possible. This is a big ask for app developers. The trouble with developing native apps is that you invest a lot of resources into projects, manage multiple development teams for each platform, spend time developing different code base, and end up reaching markets much later.

Earlier app developers adopted one of the two ways to develop cross-platform apps. You could either develop the apps in silos where you needed Xcode, Eclipse, and Visual Studio (and Objective C, Java, and C#) to develop apps for iOS, Android, and Windows platforms respectively. It was a stressful way as anytime a new UI needed to be implemented all three teams on different platforms needed to work hand-in-hand to maintain uniformity.

Or, you had platforms like Appcelator, Sencha, and PhoneGap which enabled the developer to code in one language (HTML for Appcelator, Javascript for Sencha, and CSS for PhoneGap) with one build targeting all platforms. In these cases the source code is interpreted at the run time. User experience and performance suffers.

image_9beb523f-8a48-4812-a600-818fc9630e54

Building a cross platform mobile app remains challenging because programming language, event model, UI model, and resource model all differ from one platform to other. There was a need for a platform that enabled the developers to build applications for different operating systems using a single programming language, code base, and class library. Xamarin fills up this gap. With Xamarin, developers can share a lot of the app logic between platforms while building native UIs for each platform. Time to market gets reduced and clients get fluid performance of native apps without maintaining multiple code bases.

Let’s Look at Xamarin Advantages

Xamarin is a powerful platform that has several advantages. 

#1 Feature-rich Language

Xamarin is equipped with a feature rich language C# with Lambda Expressions, Dynamic programming, LINQ, and has a rich APIs of .NET framework. Anything you can do in Objective-C, Swift, or Java, you can do in C#. Lately, Xamarin has added another powerful language called F# to its repertoire which adds to its credentials and makes it a go-to platform for app development. 

#2 Cost-effective Processes

When building on Xamarin, it is possible for you to maintain the same code base for Android, iOS, and Windows phone applications. Developers are adopting Xamarin as it is one of the most cost effective ways to develop an app on all three platforms – Android, iOS, and Windows Phone in the shortest possible time. The only platform specific code is the UI.

#3 Two Different IDEs

When developers develop apps with Xamarin, they get two different integrated development environments (IDEs) – Visual Studio or Xamarin Studio to work on. They can choose any one of them that suits them and the platform they work on. Both Visual Studio and Xamarin Studio can help you create your backend with C#.

Sqor Xamarin

#4 Compatible MVC and MVVM Design Patterns

Xamarin supports both Model-View-Controller (MVC) and Model View ViewModel (MVVM) patterns. With the help of MVC pattern the developers are able to keep application logic and presentation neatly separate. The application code as a result is easier to modify, test, update, and maintain. MVVM pattern allows the programmers to create other projects while using the same code base as and when needed. There is bi-directional databinding between the view and the view model to ensure that the models and the properties in the view model are all in-sync with the view. The MVVM design pattern is for applications that require support for bi-directional databinding.  

#5 Code Reusage

Xamarin provides the programmers option to reuse the code. This feature helps in reducing the coding time drastically. Programmers can use the same C# code for multiple mobile platforms. Possibilities become endless with custom plug-ins which can be compiled easily. Plug-ins are needed to communicate between JavaScript layer and C# layer. Once the communication is established the C# layer can be used across different devices reusing the codes.

Even though C# code becomes reusable, the UI layer remains remarkably native in the particular Mobile OS Operating Environment. Xamarin thus is extremely versatile with integrated core.

With Xamarin Forms developers claim that they achieve 96% reusability on their projects.

 CA

Source

#6 Shared App Logic 

When you build your apps on Xamarin, you need to code the application logic like database interactions, input validation, web service calls, backend enterprise integrations in C# just once. This app logic is then easily shared across multiple platforms. This saves on time and makes the builds stronger.

#7 Portable Class Libraries

Portable Class libraries or PCL make it easier for developers to share the same code base across multiple projects. The developers only need to write the code and libraries once and then they can be shared across Xamarin.iOS, Xamarin Android, and Windows Phone. PCL can be created with the help of Xamarin Studio or Visual Studio. Developers can create PCL for each platform. Interfaces can then be created to incorporate platform-specific functionality into the code.

#8 Native Performance

Unlike Phone gap or Appcelerator, apps run natively on Xamarin. The source code is compiled down to the native controls.

Xamarin is built off the mono runtime, an Ecma standard compliant .Net Framework compatible and a C# compiler tool. The purpose of mono is to run Microsoft .Net applications cross-platform and this technology builds the foundation of cross-platform mobile development here. Developers write apps in C# and share the code base across different platforms. Xamarin leverages platform-specific hardware acceleration to make the mobiles deliver native performance. C# code after compilation gets converted into native binary code. C# code for iOS gets compiled ahead of time (AOT) into ARM binary code. C# code for Android Apps is compiled to intermediate language (IL), Just-In-Time and then is packaged with Android Virtual machine-Dalvik and Xamarin’s Mono VM. C# code for windows is compiled to IL and executed by the runtime.

Apps built on Xamarin thus leverage platform-specific hardware acceleration and are compiled for native performance. Apps built on other cross-platform app building solutions interpret code at the runtime and thus cannot run natively.

#9 Native User Interfaces

Xamarin facilitates native user interfaces. Xamarin developers create app with native user interface (UI) controls. This enables the customization. Performance, look, and feel can be customized according to the mobile platform. An iOS app developed with Xamarin performs and looks just like an iOS application which is written in Objective-C. An android app developed using Xamarin looks, feels, and performs exactly like an android app developed using Java.

As a cross platform development tool, Xamarin’s uniqueness lies in the fact that it separates application logic from the interface. Application codes are shared and native interface is built for each platform. The problem arises when Xamarin’s customers have big enterprise apps to develop and they don’t want to write a new interface for each screen on multiple platforms. Xamarin.Forms solves this problem.     

Honeywell

#10 Xamarin.Forms

Xamarin.Forms is an API, a cross platform natively backed UI toolkit abstraction which helps in building user interface code that can be shared across iOS, Android, and Windows Phone apps. It is for the times the clients of Xamarin don’t want to develop native interfaces for devices on multiple platforms for an enterprise app as the size of the app is big.

Xamarin.Forms is a library that contains about 40 common UI controls and navigation abstractions that make up the UI of different apps. Controls in the gallery include abstraction of pages-iOS ViewController, Android Activity or WP Page, Composable containers for layouts such as Grid and StackLayout, Abstractions for views-buttons, labels, text boxes, date and time pickers, images and more, controls for cells that allow you to combine a label with another visual element in tables and lists. These controls are available across platforms. When used on specific platforms and compiled, they are mapped to render native UI controls to get the look and feel of native components.

You can choose and pick elements you want from both XF and native UI. Xamarin.Forms can only be used on iOS 6.1+, Android 4.0+, and Windows Phone 8 platforms. Older versions of these platforms are not compatible. 

#11 Native API Access

Xamarin makes 100% of the iOS and Android APIs available through native bindings. It is the only platform with deep code sharing capabilities across iOS, Android, and Windows apps. Developers can refer to Apple’s CocoaTouch SDK frameworks and Google’s Android SDK as namespaces with C# syntax. Developers can also access platform specific features like iBeacons or Android fragments at the same time. Native API access makes it easier for developers to use C# syntax to access platform specific UI controls.

#12 Enables High Performance Apps

Apps built on Xamarin are not interpreted; they are compiled to a native binary. This native binary compilation provides the users with fluid app performance with native user interface. Xamarin apps can therefore deliver high performance and can be used for most demanding scenarios which require multi-touch user input, smooth scrolling, sophisticated animations and graphics, complex data visualization–like for flight simulation graphics and games that require high frame rates. 

#13 Cloud-hosted Test Service

Xamarin provides a cloud-hosted test service. It provides a locally executed scripting environment to help you imitate and automate actions like a real mobile app user. It hosts more than 1,000 real non-jail broken devices in the test cloud–industry’s largest device cloud. You can run test scripts parallelly on hundreds of devices at a time. The test reports help you identify and troubleshoot bugs, UI problems, crashes, memory, and performance issues.

With the help of Xamarin you can debug your code that you can run on hosted devices of your choosing. An automated cross platform test framework handles the applications you run. With the help of Xamarin Test cloud you can integrate device testing into your build process. You get test reports that provide you performance data. It helps you ensure every release is a quality release. You can make changes in your code and see the effect of those changes by comparing different test runs.

The best part is you don’t have to write your own tests for the test cloud. Xamarin’s expert mobile app automation engineers can coach your team. You can also send your app and outsource the testing process to Xamarin. The experts author and conduct tests for you and send you the actionable report. 

#14 Xamarin Component Store

 xamarin component store

 

Xamarin Component Store is built into Xamarin Studio and Xamarin’s Visual Studio extensions so that developers can add the needed component to the app with a few clicks. There are a lot of free and paid components for developers to choose from. There are third party web services and apps, cross-platform libraries, charts and graphs, UI controls, Cloud services, beautiful themes, and other powerful features–all to enhance Android, iOS, and Windows applications. All Xamarin components include a getting-started guide and a sample project.

Some apps that were built using Xamarin are Cinemark, Mix Radio, Storyo, Novarum, Honeywell, etc.   

What do the naysayers say?

Some app developers are not too fond of Xamarin. There are practical difficulties.

It is costly. The licence cost per developer is very high. It is a new tool with a hefty price tag. Developers need to overcome a learning curve to use Xamarin–the Xamarin IDE and framework. Learning a new platform, language, and toolset takes time.  Developers need to be fluent with C#/.Net. They need to know the iOS and Android frameworks, their user interfaces and lifecycles. In short, a developer would need to know all about android app development, iOS app development, and Windows app development along with the C#/.Net the language the codes will be written in.

Xamarin will always need to be on its toes; everytime Android or iOS release a new SDK, Xamarin needs to update and release its APIs to match the SDKs as soon as possible.  Xamarin does not allow code share or reuse outside of its own environment. This proves to be a limiting factor for some developers.

It is a growing technology. Xamarin.Forms don’t address all the needs. It supports 40 UIs and controls. Developers still need access to several other Android specific UI controls. It has a smaller ecosystem. It is tough to find crowdsourced community support and solutions. Developers depend only on the Xamarin support when the bugs and other issues crop up. Productivity of designers and QAs suffer because of its smaller ecosystem.

Conclusion

There are several cross platform mobile development tools like PhoneGap, Sencha, Appcelerator, and Corona, but Xamarin is proving to be one of the most popular cross-platform mobile application development softwares.

With the help of Xamarin, app developers can now build Android, iOS,  and Windows Phone apps using the same C# codebase. The code can be written in C# and the platform agnostic codes can be shared between iOS, Android, and Windows Phone. The apps are completely native and reach the markets sooner.

Xamarin provides a new way to make cross-platform apps and has its own ecosystem. It can be a little uncomfortable and limiting for a few developers.

So, should App developers go for Xamarin? If you have the need and right resources—definitely.

Keep up with the latest DevTest Jargon with the latest Mobile DevTest Dictionary. Brought to you in partnership with Perfecto.

Topics:
mobile app development ,xamarin ,xamarin.ios ,mobile ,developer ,software & app

Published at DZone with permission of Openxcell Inc. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}