Article

Markiyan Matsekh
Markiyan Matsekh 17 August 2015
Categories

Building A Mobile Strategy With Xamarin: Win Or Loss?

Will Xamarin be the appropriate tool to implement your entire mobile strategy that can expand to 10 or 20 apps?

In the search for a cross-platform messiah, Xamarin seems to be the most viable alternative. If you are looking for the platform to build a single app, that is. But will Xamarin be the appropriate tool to implement your entire mobile strategy that can expand to 10 or 20 apps?

 

Native development is also no panacea, since it leaves us with the need to duplicate code for two or three platforms. On the other hand, PhoneGap and alike have a poor UX and a high risk of unpleasant surprises. Xamarin, though, seems to have the best of both worlds with near-native UX, up to 80% code reuse, great support from Microsoft and a fast-growing community of 600,000 developers.

 

But to answer the original question, we’ll have to take a closer look at some of the most noticeable advantages and drawbacks of Xamarin.

 
Pro: Xamarin Is Highly Effective For Heavy Offline Apps


The good thing about Xamarin is that it reuses Data Access and Business Logic Layers across platforms, leaving the UI specific to each OS. In practice, the DAL and BLL are certainly worth reusing across platforms when there’s functionality requiring computations locally on the device, like:

  • supporting the offline mode
  • handling big amounts of data locally
  • performing image recognition
  • integrating with devices over bluetooth, etc.

I’ve seen my share of apps like this in the enterprise employee-facing environment like warehouses or time tracking activities. Xamarin can reach up to 80% code reuse in these cases – that’s really impressive and makes a good use case for the platform. More importantly, when such amount of code is reused, the whole product gets a different approach. You don’t have two separate sub-teams working on iOS and Android apps; you have one team that is responsible for a single product – that’s clearly an advantage in terms of product development.

Con: Xamarin Is Weak For Apps With Heavy UI


In contrast, most consumer-facing apps vary dramatically in structures. Most efforts are focused on making the UI appealing to the customers with all the custom animations and smooth transitions (btw, here’s a good reason why, while DAL and BLL only retrieve data from the server, sometimes cache it locally and send processed information back to the cloud.

Here’s an example of the codebase size in a typical app built with Xamarin without much functionality on the device:

  • Common core – 25 kB
  • Android – 100 kB
  • iOS – 120 kB

Code reuse gets as low as 20%, while overheads and risks (which I will cover later) remain the same. And even if there is more cross-platform functionality, whenever there’s a need for custom UI, Xamarin will end up working excessively.

Unfortunately, Xamarin.Forms do not solve this problem. To quote their official webpage, Xamarin.Forms are efficient for prototyping & data entry apps and weak for custom UI & platform-specific functionality.


In general, we at ELEKS don’t recommend Xamarin for consumer-facing apps.

Pro: Xamarin Can Benefit From Both Native And .NET Development


Another great advantage of Xamarin is that it remains native, but allows developers to use C# by wrapping native libraries with the .NET layer, adding little overhead with lots of benefits. This makes Xamarin very customizable and open for all the 3rd party libraries written specially for native iOS or Android environments. So, you can simply wrap any native library yourself and use it in your Xamarin project. Additionally, if you have your back-end written in .NET, you might reuse DTO classes and app logic not only across mobile platforms, but also across the front end and the back end.

 

All this will significantly save development time as well as support efforts. In a typical case of changing class structure or adding new fields, you may only need to do it once and see the changes in mobile, back end and web platforms.

 

But even a jewel like this has limitations. While not all .NET libraries are PCL (Portable Class Library), only this type of projects can be used in Xamarin. For example, one of the basic .NET libs File.IO is not PCL, which means you’ll have to create workarounds with abstractions in code. Luckily, after Microsoft released PCL assemblies with more open licenses, most .NET frameworks became available on Xamarin and many API providers started supporting Xamarin.

Con: Finding Xamarin Professionals Is Difficult


With Xamarin, you would either need to teach a .NET developer mobile development or teach a mobile developer .NET. Even though there’s no need to learn Java or Objective-C, they would still need to learn frameworks and platform-specific app architecture with some features induced by Java and Objective-C (e.g. reference counting, excessive use of alien patterns for c#).

 

It’s challenging enough to find a great iOS, Android or .NET engineer to fit your team and corporate culture. But finding a person that would be a profound specialist in each of these technologies is next to impossible. So, you will have to combine the depth of each skillset with a versatile team, yet each team member would need to have common Xamarin knowledge. Now imagine someone leaving your team and you having to fill this void – that would be challenging.

 

Still, the situation is a little less critical when we talk about mobile strategy. If 10-20 Xamarin projects are being developed simultaneously, you’ll need a big team of Xamarin devs anyway, so team rotation may be less of a problem. The same concept applies to the next point.

Pro: On A Large Scale, Xamarin License Cost Is A Good Deal


The cost of Xamarin license is also a curious case. Usually the price is $999 per dev per platform per year. With a typical team size of 3-4 devs and assuming you have the MSDN subscription discount, you’ll end up with extra $5k per year. So, if you’re building a single app with a total budget of $40k, that may be an issue. But if you’re building a 5-year plan with a dozen of apps, six figure budget and a core team sharing projects and licenses, you may feel just fine.

Con: Xamarin Still Brings Risks


In the end, all cross-platform solutions bring risks of unplanned or excessive work. As I mentioned before, among other similar platforms (PhoneGap, Appcelerator, Kony, IBM WorkLight, etc.) Xamarin is probably the best compromise between the risk and the reward. But don’t forget the risk is still there.

 

One of the scariest areas is garbage collection. Take a look at the official docs on the topic. With Android, Xamarin has 2 Virtual Machines running in parallel – Android Runtime VM and Mono Runtime VM. The former is the default VM which works the same way as in the native environment.

 

The latter is a runtime which allows all the .NET features to be used in mobile apps. Both of the VMs have their own garbage collection, and that would have been just fine if only they didn’t intersect. The problem is that there are cross-referenced objects between these runtimes, and that results in complex garbage collections mechanics which may cause significant delays in the app.

 

With iOS the situation may be even more difficult due to manual reference counting which, if not treated very thoroughly, can lead to memory leaks and app crashes. Obviously, the Xamarin team has now advanced in this direction a lot (with things like New Refcount), but the area is still error-prone for a lot of engineers.

 

Similarly, you may run into a show stopper when trying to implement something native with Xamarin. Leaving aside numerous UI examples, this may happen with such basic objects as Generics.

 

Additionally, Xamarin’s framework libraries lead to excessive app file size to be downloaded from Google Play or App Store. The difference varies between 3 MB and 15 MB depending on how much core library functionality is used in the app.

 

Conclusion: Xamarin In Mobile Strategy – You Never Know

 

Taking into account all the pros and cons of Xamarin mentioned above, the question for building a single app would be simple: is the reward worth the risk? And in most cases, with clear functionality requirements and business priorities (e.g. UX over cost), it’s easy to find an answer. But if you’re still not sure what your apps will look or behave like, the answer is far from obvious.

 

Thus, My Recommendations Are:

 

  • If you’re confident that most of your apps will be employee-facing, that cost cutting is more important than slick UX and you’re used to .NET as your default technology, then Xamarin is a great option.
  • If you know your apps will be mostly consumer-facing, UX is more important than the cost and there are some uncertainties in the development, stick with native development.
  • If you don’t know what apps you’ll have to create yet, it’s a matter of risk taking. You either pay less now with a risk to pay twice in the future (choose Xamarin now with a risk to mix native and Xamarin in the future) or pay more now to avoid paying 2x in the future (stick with native).

And finally, if you’re in doubt, the best option is to ask for a professional consultation ;)

 

Original Article

 

Find out more on the future of Technology at our DLUK - Trends Briefing on the 24th September 2015

Please login or register to add a comment.

Contribute Now!

Loving our articles? Do you have an insightful post that you want to shout about? Well, you've come to the right place! We are always looking for fresh Doughnuts to be a part of our community.

Popular Articles

See all
How to Review a Website — A Guide for Beginners

How to Review a Website — A Guide for Beginners

A company website is crucial for any business's digital marketing strategy. To keep up with the changing trends and customer buying behaviors, it's important to review and make necessary changes regularly...

Digital Doughnut Contributor
Digital Doughnut Contributor 25 March 2024
Read more
The Impact of New Technology on Marketing

The Impact of New Technology on Marketing

Technology has impacted every part of our lives. From household chores to business disciplines and etiquette, there's a gadget or app for it. Marketing has changed dramatically over the years, but what is the...

Alex Lysak
Alex Lysak 3 April 2024
Read more
7 Reasons Why Social Media Marketing is Important For Your Business

7 Reasons Why Social Media Marketing is Important For Your Business

In the past two decades social media has become a crucial tool for marketers, enabling businesses to connect with potential customers. If your business has yet to embrace social media and you want to know why it is...

Sharron Nelson
Sharron Nelson 29 February 2024
Read more
AI-driven Personalisation Dominates the Future of Travel and Hospitality Marketing

AI-driven Personalisation Dominates the Future of Travel and Hospitality Marketing

Travel and hospitality marketing is on the verge of dramatic transformation. Personalisation of marketing communications is moving from dream to necessity, and the change is putting marketers in the driving seat.

Michael Nutley
Michael Nutley 3 December 2024
Read more
Sales and Marketing Collaboration: A Recipe for B2B Success

Sales and Marketing Collaboration: A Recipe for B2B Success

In the world of B2B, the age-old rivalry between Sales and Marketing often overshadows the potential for a fruitful partnership. Yet, when these two departments align their goals, strategies, and efforts, the results...

Zsofia Raffa
Zsofia Raffa 12 September 2024
Read more