Xamarin, the best mobile application development solution for you? (Part 2)

I invite you to see my opinion on whether “Is Xamarin the best mobile applications development solution for you?” in this second part. If you haven’t seen the first part yet, you can see it here.

In the first part I put you in context, for the new ones, with some of the basic definitions within mobile development. I told you about what happened in recent years with the development of mobile applications; the criticisms and how were my beginnings with this tool. This time I will expose the pros, cons and paradigms; among other things. With this you will have a general knowledge about it. If there’s a need to choose between tools, you’ll be able to know if Xamarin has what you’re looking for.

So, let’s start…

¿Why Xamarin?

XAMARIN is a set of tools that covers different platforms (Android, iOS and Windows Phone) from a single .NET base code creating completely native applications.

When I started in the world of development, I started with .NET technologies with Windows Forms thanks to a math teacher at the beginning of my university career. After trying to follow “the right way” (the most requested jobs); I started with web development with HTML, CSS and JavaScript. Once I thought I had mastered these web development technologies, I started working with MVC and other tools.

super xamarin by luis matos

When I was asked to investigate the mobile development tools to later choose one, it was a bit complicated. I had the best of both worlds (C Sharp – JavaScript). In the end, I ended up choosing XAMARIN because I felt more identified with the .NET technologies because I had more experience.

The truth

The truth is that I was a little afraid. Although I had worked with JavaScript, I hadn’t had the opportunity to venture into one of its frameworks. This I translated as more work on the learning part by choosing a tool based on JS for mobile development.

I think if I had more experience with a JS framework than with .NET I would have chosen a tool based on JS. Not because these are better. It’s because the line of learning would be less painful. So, I could get more out of the platform in a shorter time.

Of course, I know that many of you are not in the same situation as I was. In that sense you can investigate more thoroughly all the tools that you think meet their expectations. So, you can make an analysis to choose one or the other. Now, I’ll give you some advice: “When you go to analyze a tool, try to analyze its future trajectory“. This is where everything makes sense.

The bad                                    

developer burning at work

No matter how beautiful and novel the tools are, we’ll always find pros and cons, this’s normal. In the case of good tools, we will only find specific cons. Those can only be detected if you work with it day by day. That’s why in this case I’ll only mention some things that I think are the ones that could be improved. Maybe there are more but these are the ones that come to me at this moment.

Xamarin Live Player

Many people complained because there was no way to visualize your UI without compiling the application. It’s here that this wonderful tool is born. This makes it possible for us to visualize our user interface designs with Xamarin.Forms in real time. The problem here is although it’s very wonderful it has many limitations for advanced developers; it can bother a little.

These limitations are:

  • Custom Renderers are not compatible.
  • The effects are not compatible.
  • Custom Controls with customizable custom properties are not compatible.
  • Embedded Resources are not compatible (that is, embedding images or other resources in a PCL).
  • Third-party MVVM frameworks are not compatible (i.e. Prism, Mvvm Cross, Mvvm Light, etc.).
  • The Asset Catalogs on iOS is not compatible.

The only way I can use this tool has been to create a separate project and create my designs with normal controls. Then pass them to the main project and replace normal controls with my custom controls. Sometimes this can be a tedious process, mostly when you have to do an update.

To see more about this topic, visit the official website here.

Unhandled Exceptions

For those who are a little more experienced with XAMARIN know that many times our application didn’t compile for this type of exceptions. Mostly related to the XAML and in other rare cases with specific things.

Many times our applications couldn’t compile. Maybe of a syntax error in our XAML, something that was critical for a while for Xamarin. These criticisms were greatly reduced with the introduction of XamlCompilation. This allows a compile-time check of XAML that notifies us when there are errors. So far so good, the bad thing is that when you work with custom controls and a little complex UI; we still have some problems as before, to a lesser degree, of course.

Sometimes some unhandled exceptions also appear and that no matter how much you debug your code line by line (as I did). You will not find the problem since the exception doesn’t give much information to say. In these cases something that helped me a lot although with a little work, was the handling of global exceptions within each platform. While it’s a bit tedious, it’s better than having to deal with the code line by line.

To see more about the XamlCompilation, visit the official website here. For handling global errors, you can see some examples here.

Incomplete controls

Although XAMARIN has all the necessary controls to build a stable application model; the truth is that there are a few controls that give us the impression of being incomplete. This you can only perceive if you have worked a lot with Xamarin.

Some of these controls are:

  • SwichCell that doesn’t support DataBinding.
  • ViewCell that doesn’t support Commands.
  • NavigationPage that doesn’t detect when the user navigates backwards,
  • And others.

Although this isn’t the end of the world because with these controls you will have to make your own implementation. The truth is that it was easier for the developers if these functions were supported by the controls as others do.

In this case it’s more a personal opinion. I know that there is a team that works hard to have the best features within the platform.

The good     

developer-feliz-trabajo

Xamarin, like other tools, has multiple benefits due to the cross-platform development approach. In this section we’ll not talk about the benefits of cross-platform development, nor about communities, tools, or things like that.

What I do next is to show you a little about the most important aspects. In my opinion, those are what make all the magic possible with Xamarin.

.NET Technology

tecnologies

Xamarin uses a single language (C#) to create native applications for all platforms. C# is a mature language strongly typed with security that prevents the code from behaving unexpectedly. Since C# is one of the .NET framework languages, you can use several useful .NET functions such as Lambdas, LINQ, asynchronous programming, etc.

For developers who don’t have experience in mobile development, but know about these .NET technologies, have the possibility of easily adapting to the mobile application development environment with Xamarin. More if they use Xamarin.Forms to share UI and logic of the application.

To see more about .NET, visit the official website here. On the other hand if you want to know more about C #, you can start here.

Cross-platforms

At first when developers heard that Xamarin can be used to develop mobile applications for iOS, Windows and Android; many of them were a little surprised because Windows Phone only supported the C# language.

cross-platform-development

With Xamarin we can create applications with a totally native user interface. Not only complying with the standards, but also the behavior expected of each platform. On the other hand we also have access to all the native API of each platform; we can access all the functionalities that the device exposes. All this taking advantage of hardware acceleration of the specific platform to compile the applications and have a native performance.

If you are a developer and don’t know XAMARIN, you will be surprised to know that with Xamarin we can also develop desktop applications for macOS and Windows. This’s a great advantage over the competition, more for companies and developers who like to work in different platforms. And as a final plus Xamarin also supports Smart Watches.

To see more about cross-platform development with Xamarin, visit the official website here.

Two Approaches

Within XAMARIN we can develop applications under different approaches in the project architecture. One of these approaches allows you to share the user interface for each platform. And the other allows you to share the logic of your application between projects of each platform.

XamarinTypes

If we want an application that shares the same user interface controls between platforms we can use Xamarin.Forms. On the other hand if we want to share common code (Resources) between platforms but not share the user interface then we can choose a project with Xamarin Traditional.

To see more about these approaches, visit the official website here.

Xamarin.Forms

This is the product designed to create native applications exposing a complete set of cross-platform user interface tools for .NET developers.

Xamarin.Forms is a framework that allows developers to quickly create cross-platform user interfaces. This means that applications can share a large part of their UI code and still retain the native appearance of the target platform.

To see more about Xamarin.Forms, visit the official website here.

Custom Functions

Many times when we need a control to comply with a specific functionality or appearance. Perhaps a control that the platform as such doesn’t provide, in that case, you will need to customize that control. Other times what we need is to access a specific functionality of the platform, such as battery information or check the device orientation. For these specific cases Xamarin.Forms provides an abstraction of classes to access those functionalities and native controls of each target platform.

app development

In the case of controls, Custom Renderers are used to customize the look and behavior of controls on each platform. On the other hand we have the Effects that allow the native controls of each platform to be personalized without having to resort to an implementation of a Custom Renderer.

Finally, Xamarin.Forms allows developers to define the behavior in specific projects of the platform. With DependencyService you find the correct implementation of the platform, allowing shared code to access the native functionality.

To see more about CustomRenderers, Effects, or DependencyService visit the official website.

Software architecture patterns

While applications are modified, and grow in size, more complex becomes maintenance. Having a pattern that helps you clearly separate the user interface from the application logic of your development environment becomes more productive.

With Xamarin it’s easier for developers to adopt patterns such as MVVM or MVC. There are some external Nuget libraries to take advantage of these approaches with features like DataBinding, Commands, etc. And why not talk about extensions for Visual Studio as Prism Template Pack? This fantastic library contains a collection of snippets, element templates (View and ViewModel) and project templates for use with WPF and Xamarin.Forms applications using Prism.

To learn more about the MVVM design pattern, visit the official website here.

Testing

One of the great advantages that XAMARIN has, compared to other solutions, is undoubtedly all the tools Microsoft provides to test our application. And not only this, but thanks to the MVVM design pattern we can maximize our code to implement unit tests easily.

For example, using Xamarin UITest we can automate tests of our user interface on hundreds of devices in the cloud. And not only that, Microsoft provides you the tools so you can form your own QA environment to launch more quality applications.

To see more about automated testing, visit the official website here.

Microsoft power

Without a doubt I think that this is one of the biggest advantages that XAMARIN has. It’s because Microsoft doesn’t stop surprising us in each update. One of the things most acclaimed by developers has always been the design editor on the platforms, which at first didn’t exist and Microsoft has added. Day by day it continues to improve it. For those with VS Preview, you can already see hints of the highly acclaimed “Drag and Drop” with XAML. And that’s not all!

microsoft-love-xamarin

Not to mention the details of each update that Microsoft makes to Xamarin, we must mention all the effort that this company has made to provide us an entire working environment with DevOps technologies, integrations with Azure to create more complex applications, etc. to make life easier for companies and developers. I think the best thing that has happened to Xamarin is that he is part of Microsoft ♥.

To see the official Microsoft page, click here.

Paradigms

Many developers who don’t know or have not worked in the development of mobile applications, have a set of knowledge and beliefs based on the opinion of others or on the surface of other tools to form their own vision. This also applies to those who use other tools and want to make comparisons of two totally different things without taking the proper time to thoroughly analyze said tool.

These people based on a theory of a certain period share their knowledge to determine the direction of a certain tool. In this case I will talk about some of the most common paradigms that other developers use to criticize XAMARIN.

Write once, run anywhere

This’s the motto of Xamarin.Forms. The truth is that the more complex your application is, the more you will have to make use of specific functionalities of the target platform. So, that 75-90% shown may vary depending on your application.

Personally, I have launched applications without using custom controls or specific functions of the platform. What I have had to work on each platform are the styles, home screen and those things that should be done in almost all applications with Xamarin. If you are one of those who puts a lot of effort to the UI / UX maybe you will do some extra work.

App Package Size

It’s true that all cross-platform development tools generate heavier installation files than native tools. In this sense Xamarin is not far behind as it generates an APK (Android) of 15.8 MB (before there were more) for a simple “Hello world“.

Package size before linker

This is one of the main criticisms that XAMARIN has. This’s taken as reference to compare it with other tools. What these developers don’t know is that this installation file is for debugging purposes, not production or distribution.

Now, when our installation file doesn’t have any code that is not directly used (this can be achieved through the Linking process) or it is occupying space then our “Hello world” will be 2.9 MB which compared to other cross-platform tools, size is smaller.

Package size after linker

To see more about the .apk size in XAMARIN, visit the official page here. To see some comparisons using different approaches with Xamarin, see here. And to see other comparisons with the native platform and other cross-platform tools, see here.

Xamarin.Forms Limitations

Knowing that Xamarin.Forms supports around 40 controls and layouts. It’s logical to deduce that when you are working on a customized project you will need some specific templates. This’s when you ask yourself what you can do, and of course the solution to this is easy, you just have to use Custom Renderers. The truth is that it can be a bit difficult to design these controls if you don’t have much experience in each target platform.

Luckily for the entire community, there are developers who are dedicated to doing this type of controls. We can use all these controls, on rare occasions we will not find controls that others have not already done.

Few controls

As I mentioned earlier Xamarin.Forms has about 40 controls and layouts. This could be translated as very few for some developers. The truth is that Xamarin provides the necessary controls to create any type of application, the challenge is when we need some specific controls.

Xamarin receives much criticism for this and is that many developers. For example, want controls such as the FAB (Floating Action Button) on all its platforms. But what they don’t realize is that perhaps a control doesn’t meet the standard design of the target platform. This is the case of the FAB, in Android this is a very common control and recommended to use in the user interface. However, in iOS it’s not advisable to use this type of controls in the UI since it doesn’t comply with the standards of the platform.

To see all the controls in Xamarin.Forms, visit the official website here. Material Design for Android and iOS.

Live previewer

Before this was one of the most criticized topics of Xamarin because he didn’t have a way to edit your designs in real time. The truth is that it doesn’t remain that way, since the GorillaPlayer came out, by a third party, this changed. However, it was still a point of criticism since we had to resort to a third party to receive this functionality.

business-man-happy

Today we already have several options for design in real time, these are:

  • XAML Previewer. This helps you see your designs with Xamarin.Forms as you type your code.
  • Live Player. This runs your application within an App installed on your mobile to help you test your application without compiling your application.
  • Live Reload. This is a new feature that is similar to Xamarin Live Player but with extra features such as debugging your application and making changes to the XAML that will be reflected live (supports physical devices).

Start time in the Splash screen

Something that catches the attention of many developers is the time it takes the application to start. And it’s clear that having an application that lasts 8-10 seconds to start is not very well seen by users.

administracion del tiempo - xamarin

The truth is that making use of good practices and optimizing the resources of the application will reduce the application‘s start time, although not as much as we would like. This is where AOT comes in and it can greatly reduce the start time with 2-3 seconds. Very nice, right? Well it is not, since this approach multiplies the size of your application as x6.

My personal opinion is that I prefer the user to download an application of 40-50 MB once, instead of every time he opens the application it takes 8-10 seconds to start. Of course if you optimize your resources you can reduce the time considerably. On the other hand, if we want to use other approaches and look for a midpoint you can see here or here.

To see some techniques on how to reduce start time, you can see here. To see the average time using one or several approaches, you can see here.

Never use Code Behind

If you are new and don’t know what the code behind is, pay close attention. Xamarin.Forms uses XAML to design the user interface. The .xaml files (XAML) are linked to an .xaml.cs file (C Sharp) that handles events, references and specific functionalities. This second file is the one that refers to the code behind.

Xamarin.Forms with the MVVM pattern divides the user interface and the application logic. So, if I’m going to use MVVM, why use code behind? When you’re starting in the world of Xamarin.Form it’s normal to hear such comments. The people who make these kinds of comments are people who have little experience with Xamarin. The truth is that there’re several reasons why you have to use code behind but everything will depend on what is needed.

Although I will not go into these reasons, I give you some examples so that you understand the idea. Here the examples:

  • The SwithCell doesn{t allow Binding properties with the ViewModel. In this case it{s necessary to use an event and a reference of the VM in the code behind to update the property in the VM.
  • To detect when the user presses the backward button, you must implement the OnBackButtonPressed method in your CodeBehind.
  • Animations are handled in the code behind.
  • Etc, etc, etc.

With this, don’t misunderstand. The best practice in this case is not to involve the logic of our application in the code behind. Everything that will be handled in the code behind must be related to the user interface only. This will ensure better long-term support.

To see the first steps with XAML, visit the official website here.

Price

This is one of the great controversies when comparing tools. In this sense, XAMARIN was previously licensed, not anymore. Now it’s only necessary to have the visual studio with Xamarin to start working. Of course, if you want more features to take advantage of the entire work environment with XAMARIN, you will want to upgrade your Visual Studio subscription to Enterprise. With this I’m not saying that VS licenses are the cheapest in the world, what I think is if you are a company you would not have problems to obtain these licenses.

Whether you are a FreeLancer developer or a company, having the VS Enterprise license is a good option because it gives you functionalities to launch more quality applications by streamlining your work environment. If you are one of those who are testing or learning with XAMARIN then I think you won’t have any problem with VS Community.

To see a comparison between VS versions, see the official page here. To see the prices here.

Conclusion

If you were waiting for me to say that Xamarin is the best solution for the development of mobile applications then I regret disappointing you. The truth is that everything will depend on the situation.

Many native developers don’t give the opportunity to new options because they don’t want to leave their comfort zone, and this’s understandable in a certain sense. Before there was a fear to think that what facilitates mobile development had to be bad, today we see how things change.

On the one hand we have the cross-platform development that has something that the native doesn’t: the ability to share code between platforms. If you are a web developer and you believe that this is the best time to make your jump to mobile using everything you learned with either React Native, NativeScript, Ionic or another tool that uses HTML, CSS and JavaScript, then do it.

Facebook, Instagram, Uber Eats, are some of the applications that use millions of users every day and were created using JavaScript as a language and React Native as a library. This has all the logic of the world, since they have their web application also with JavaScript, in this sense the support and experience of their developers is something that is in their favor.

 

For developers who like Microsoft technologies, C# now allows you to reach iOS, Android and Windows Phone thanks to Xamarin. In the same way if you need a project that you are going to work with. NET technologies to create web pages, desktop applications or Mac with a mobile application to add value, it is advisable to use XAMARIN to get more benefit to your development team and streamline processes by sharing code to improve cross-platform support.

Special cases

On the other hand, there will be cases in which there’s no other option than using native development and official languages, since it’s the only way to access things at very low level and the latest APIs of the operating system. But at the level of performance or user perception will be very little difference against something native or created using some other language.

Of course, these are not rules that must be followed letter by letter. Everything will depend to on the project and the company or developer that works with these elements. If the developer or company only know a single technology for mobile development no matter what it is, it’s advisable to use that at least until they have experience in other tools and after an analysis can decide what is best for future projects.

Similarly it does not matter if you use Js, .net or other; If you think that in another tool, which uses different technologies than the ones you use, you can get more value for x or y, then use that tool and take advantage of it. Here I have spoken that the best thing would be to use the tool that has the technologies that you control, but the truth is that if you have the time to venture into another tool that you think has a long-term future, you can do it and nothing will happen, otherwise you are betting on the future.

I have seen web developers with JavaScript who have chosen to develop mobile applications with XAMARIN because they see a splendid future in this tool by having Microsoft support knowing that this company will do the impossible for it to continue improving.

Personal opinion

In my beginnings I also had these doubts about which tool to choose and for my fortune I count on the support of very valuable people for me, people who are sufficiently qualified to give advice in that sense. One of these people when I asked him about this topic told me something that marked the rest of my life and that I still believe faithfully in what that person told me. That person told me the following: “It’s not the tool, it’s the developer“, very similar to the saying “It’s the Indian, it’s not the arrow“.

xamarin developer - luis matos

At the end the decision between one platform and another should be based on your skills and knowledge that you handle. For me it is impossible to recommend XAMARIN for people working with React, for example, it would be like starting from scratch. If you have a team that uses React for development and you can take advantage of that talent to develop mobile applications, I think you’ve chosen the right option.

Now, when the .net community has doubts about which tool to choose for supposed doubts and because to a greater extent JavaScript is attracting the attention of many; I can only recommend XAMARIN based on what I think is the right thing to do.

If in your team you have developers that work with JavaScript to work the web pages and you have others that work mobile applications with XAMARIN, nothing happens either. In the end it’s the experience of the developer and their capabilities that will determine the quality of the final product.

So, if you’re looking for references, you’re new or you’re trying to start in the world of mobile development now, you know the history behind Xamarin,. You can make a decision. Only you know if Xamarin is the best solution for you needs.

This’s all for now, see you next time!

Thank you somuch for reading this post! 
Xamarin, the best mobile application development solution for you? (Part 2)
5 (100%) 5 votes

feedback

I hope this post can be helpful for you and if you think that can be helpful for others, share it with them. I invite you to leave me your feedback about this post in the comment box. If you want me to talk about a specific topic or detail a few more topics, let me know. The most interesting topics will be added to my list of future posts.

Do you like posts like this? Then, subscribe  and activate push notifications to receive updates. See you next time!

Others
2019-02-07T10:44:48+00:00

3
Leave me your comments

avatar
3 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
0 Comment authors
Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
trackback
Xamarin, the solution for the mobile applications development? (Part 1) - Luis Matos

[…] Next […]

trackback
Label's New Features: Xamarin.Forms 3.3.0 Update - Luis Matos

[…] If something is true, it’s that Xamarin listens to the community. This time the Xamarin’s team, in response to the requests of the […]

trackback
Hello Microsoft Learn / Good Bye Xamarin University - Luis Matos

[…] I think we can still show the certification as part of our journey in the world of Xamarin and will still have its value. And what do you think? I would like to see your opinion about this […]