Cross-platform evolution: the pros and cons of Xamarin

Original author: Craig Knighton 
  • Transfer


Like the era in our own history, when four-legged mammals made a leap in evolution and became two-legged, Xamarin.Forms is trying to leave its mark on the history of software development, architecture and design. Thanks to its capabilities, we can easily develop an application (having previously created our own unique design for it) that can run on three different operating systems with the same C # code base and user interface, and for which it is possible to reuse the code and customize it.

I also decided to participate in this important milestone in software development. After I developed an application that helps me control the health of patients, I decided to share my opinion about the pros and cons of Xamarin.

Weigh all the “pros” and “cons” of Xamarin


What I managed to create


In recent years, I have devoted most of my time to health issues. I was inspired by the idea to develop something new that would allow me to more effectively monitor the health of patients, as well as record their biometric data. For this purpose, I developed a panel for collecting patient health data. Thanks to it, you can collect information about patients: their cholesterol level, waist-to-hip ratio, body mass index and heart rate, as well as track any changes in these parameters over a certain period.

All monitored indicators are displayed in the form of a square grid with nine cells. The user selects the desired cell (for example, a cell with cholesterol level indicators), the indication of which he would like to track. After selecting such a cell, the following screen appears before the user.

Being in the main menu, the user receives color signals if updating is required for any indicators. The indicators that were recently introduced are displayed in bright green, but over time the color fades to black. After the indicator has turned black, it needs to be updated. The panel also displays the history of the entered indicators. In the future, it is planned to add more graphics to the panel interface.

Disadvantages and advantages: development for Android was more convenient than for iOS


First of all, I started developing and testing my application using Xamarin.Forms for Android. It just so happened that until this time I, for the most part, wrote various applications for iOS on Objective-C. I had to install Visual Studio on my Windows and use it to bring my idea to life. Since Android emulators were very, very slow, I had to take the path of least resistance: I monitored the process and checked the functionality of the application on a regular Android phone, since debugging using the phone in Windows is only supported for Android devices.

To verify the correct development of the coveted panel for iOS, I had to devote a bit more free space. While I continued developing on Windows, my iPhone, used for debugging, had to be constantly connected to the Mac (or to the work node). Then, I connected the Mac to the same Wi-Fi network that my computer used directly for development was connected to. What for? It's simple: during development and debugging, Visual Studio IDE and Mac had to interact. Using an SSH connection, I was able to “make friends” with Visual Studio and Mac OS by setting up access to the Apple compiler, as well as tools for signing executable code.

The difference in my experience testing applications for Android and iOS is, in fact, insignificant. When debugging an application developed for iOS, I had to constantly be in the same room, because my computer was connected to a work node. As for Android, I felt much freer, and testing was many times faster: I updated applications, turned to another device and started the application again. Thus, I decided that, first of all, I will develop and test the application specifically for Android. As for my experience with Xamarin, such disadvantages and advantages became the most significant during all my work with this platform.

Benefits: Providing functionality with Xamarin.Forms built-in layouts


To develop a panel for collecting patient health data, I used the built-in layouts in Xamarin.Forms using the user interface code. I chose the built-in layout with a linear arrangement of objects with nested grid layouts in them. To do this, I created my own layout classes, thanks to which I achieved more functionality. I also developed a general view of the “cells” in the grids that would relate to the specific indicator under study, so most of the code for the cell (including assigning measurement limits to any of the indicators, as well as determining its color) was also used by me to develop other cells .

What is important, developing my idea with the help of Xamarin.Forms, I wrote code that seemed to say: "For the first cell, create a new line for me, and for the second cell - a grid." This approach seems to me very convenient for developers who are used to writing their own and understanding other people's code. Nevertheless, it seemed normal for me to write my own page layout, especially if in the future I have to make changes to the code and change the layout again. If you have no other reason than to use XAML designer, I would advise you to write screen layouts anyway.

Imagine my surprise when I, having just written a draft version of my application for Android, discovered that its orientation changed with the rotation of the device. The design of Xamarin's built-in layouts was designed to be responsive so that the application completely fills the device’s screen. Personally, I was not going to engage in support for changing the screen layout. As far as I know for development teams using Xamarin, such features of this platform are a lot of saved time. I was even more surprised when I installed the application on my iOS gadget and found that it works and all its responsive features remain!

Pros / Cons: Resolving Constraints Using Model View ViewModel


Since I did not involve a designer to work on my project, there were no classical troubles between the developer and the designer (for example, the designer provides a layout with a UX / UI design to a developer who, for a number of technical reasons, cannot put it into practice). Competent interaction between designers and developers is the key to achieving an elegant UI design using Xamarin.Forms.

When developers start working on the mobile version of the application using Xamarin.Forms, they should, first of all, think carefully about what the common features for the devices of the most common systems: iOS, Android and Windows will look like. Each developer should ask himself: “Is the functionality of the application supported, and also are all its elements in place, when working on any systems? How can this be achieved? ”

Such a process requires more organization, as well as in-depth knowledge of interaction schemes in all three operating systems. During application development, you need to be guided by solutions that are universal for all possible operating systems, and not rely, for example, only on Android, while completely forgetting about users of iOS devices.

And yet, I did not rely on UX design for my simple application, since the development of a flexible layout using Xamarin.Forms was an undeniable advantage that allowed me to reuse the code more efficiently, saving 80–90% of the time. In addition, some behavior patterns of a system can be tracked using the DependencyService in Xamarin.Forms.

Instead of throwing all your strength into a UX / UI design, try to understand the limitations for a particular operating system. By doing this, you can undoubtedly be able to create truly worthwhile things, despite such boundaries. Of course, such concessions made to achieve the benefits of using Xamarin.Forms cannot be a decisive factor. Nevertheless, it is worth noting that if a more specific specificity for the system is required, then developers can create their own render.

Design Principles with Xamarin.Forms


(Warning, spoiler from the developers!) The following are examples of best practices for frames and aesthetic layouts for Xamarin:

  • Strive to create an application that is universal for all systems.
  • Check out the limitations of each system.
  • Think over the steps for developing your application: how you will develop it for operating systems.
  • Synthesis first, then design
  • You should not consider functionality as something that works only on Apple devices, especially when it comes to C # and SDK.
  • Avoid the temptation to abandon familiar interaction patterns. Why? Where possible, Xamarin uses built-in controls, so the iOS and Android “text edit” controls look and work like the default controls for each corresponding OS.

Pros and Cons: Add Animation at Download Time for Your Users


At the end of this article, I want to advise you also to pay attention to what we are faced with from the very beginning - the waiting time required to download the application. After I finished working on my panel, I noticed that it took a little longer to load it than I expected: it displayed the results from the server for display. If from the very beginning I would add the animation displayed during the loading process, then such a delay would go unnoticed. This, of course, is a minor detail in the discussion of the advantages and disadvantages of Xamarin, however even the smallest detail matters.

- Bourges Traffic from Reddit, Medium, Bitcointalk .

Also popular now: