7 Ways to Boost Your Xamarin Development Productivity
Tags: productivity, android, ios, csharp
Published: 2019-11-28 05:27:41

---
title: 7 Ways to Boost Your Xamarin Development Productivity
published: true
date: 2019-11-27 12:00:36 UTC
tags: productivity,android,ios,csharp
canonical_url: https://www.syncfusion.com/blogs/post/7-ways-to-boost-your-xamarin-development-productivity.aspx
cover_image: https://www.syncfusion.com/blogs/wp-content/uploads/2019/11/7-Ways-to-Boost-Your-Xamarin-Development-Productivity.jpg
---

There are many ways to improve your productivity when developing a Xamarin.Forms application. Here, I have summarized a few things from my own experiences. The following are the phases of typical Xamarin.Forms application development:

1. Design
2. Develop business logic
3. Build
4. Test
5. Deploy

The following are the most common tools and techniques that improve the life-cycle phases of developing an application in Xamarin.Forms that I will discuss in this blog:

- XAML
- Patterns
- Open-source libraries and frameworks
- Custom controls
- Rapid iteration using Hot Reload
- Build-time optimization
- Continuous integration

## XAML

The appearance and performance of your application depends on how you organize and present UI controls in Xamarin.Forms. It is necessary to nest different layouts and controls to create your desired UI. Creating and editing different layouts and various controls in the code-behind will make it difficult to read and clumsy to work with. So, the better solution is to use XAML in all possible cases.

### XAML code: easier to read and maintain

XAML code is easier to use and read when compared with its equivalent counterpart, C# code. Compare the following simple example XAML and C# code.

XAML
```xml
<StackLayout>
<Label Text="{Binding Name}"/>
</StackLayout>
```
CSharp
```csharp
StackLayout stackLayout = new StackLayout();
Label nameLabel = new Label(); 
nameLabel.SetBinding(Label.TextProperty, "Name"); 
stackLayout.Children.Add(nameLabel);
```

### XAMLC

A few months back, before recent Visual Studio and Xamarin updates, XAML files were embedded along with executables when deployed. Now, XAML files are compiled along with the C# files, known as XAMLC compilation. This feature is enabled by default when creating a Xamarin.Forms application (at the time of writing, I am using Visual Studio 2019 version 16.3.6). If you are not using the updated versions, still you can enable XAMLC by following the steps in this [documentation](https://docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/xamlc).

#### **How does enabling XAMLC boost your productivity?**

- It performs compile-time checking of XAML, notifying the user of any errors.
- It helps reduce the file size of the final assembly by no longer including .xaml files.

### Design-time data

Design-time data can be used to visualize a UI with mock data. It is very useful when you do not have the ViewModel before you start building the UI. Design-time data populates mock data in the XAML Previewer to visualize the XAML layout. Refer to [this blog](https://montemagno.com/xamarin-forms-design-time-data-tips-best-practices/) for more details.

## Patterns

There are many patterns you can choose for your application. This Microsoft [documentation](https://docs.microsoft.com/en-us/xamarin/cross-platform/app-fundamentals/building-cross-platform-applications/architecture#common-mobile-software-patterns) outlines a few standard patterns. The most commonly used one is the [Model-View-ViewModel (MVVM) pattern](https://docs.microsoft.com/en-us/xamarin/xamarin-forms/enterprise-application-patterns/mvvm). This pattern helps to clearly separate the business and user interface logic of an application. Following the MVVM pattern will greatly help you maintain, test, and evolve your application by eliminating duplicate code and increasing the possibility of reusing code. It allows developers working on business logic and designers working on UX designs to work independently and simultaneously, improving the project’s productivity.

## Open-source libraries and frameworks

It’s often accurate to apply the statement, “All the easy problems have already been solved,” to software development. Therefore, you just have to pick the right solution. Coming to Xamarin.Forms, there are many open-source libraries waiting to be used. You can skip most portions of the design phase of your application by using the following open-source projects:

- [FFImageLoading](https://github.com/luberda-molinet/FFImageLoading): Library for loading images quickly and easily on Xamarin.iOS, Xamarin.Android, Xamarin.Forms, Xamarin.Mac/Xamarin.Tizen, and Windows.
- [Essential UI Kit for Xamarin.Forms](https://www.syncfusion.com/essential-xamarin-ui-kit): Elegantly designed XAML templates for Xamarin.Forms applications. These templates are compatible with Android, iOS, and UWP platforms, and use the MVVM design pattern to provide trouble-free integration. You can get the complete design implementation for free from [GitHub](https://github.com/syncfusion/essential-ui-kit-for-xamarin.forms).

Though you can develop applications based on the MVVM pattern using the features available in the Xamarin.Forms framework, there are still certain items you have to do on your own, such as navigation services. Instead of writing your own implementation, there are many MVVM frameworks available you can use to save time. Some of the widely used frameworks are:

- [MvvmCross](https://github.com/MvvmCross/MvvmCross)
- [FreshMvvm](https://github.com/rid00z/FreshMvvm)
- [MVVM Light](https://github.com/lbugnion/mvvmlight)
- [Prism](https://github.com/PrismLibrary/Prism)
- [Caliburn.Micro](https://github.com/Caliburn-Micro/Caliburn.Micro/)

## Custom controls

When you create a Xamarin application, most of the time, it is not possible to achieve your expected UI with the framework controls. So, you end up creating multiple custom controls and platform-specific renderers. Creating your own controls is a desirable choice, only if it doesn’t require too much work to create and maintain them.

Using third-party custom controls is a solution that reduces design and maintenance costs of your application. For this, Syncfusion—a market leader in Xamarin.Forms components—has [145+ Xamarin UI controls](https://www.syncfusion.com/xamarin-ui-controls) that can be used in your application for all scenarios, and provides simple and straightforward [licensing](https://www.syncfusion.com/sales/licensing).

## Rapid iteration using Hot Reload

Until a few months ago, you had to build and deploy again and again to verify even the simplest changes in Xamarin.Forms applications. This was quite a time-consuming process, recompiling and redeploying the entire application for every little change. _Hot Reload_ is a great feature recently introduced by the Xamarin team that addresses this. With the Hot Reload option enabled in Visual Studio, the changes you make in the XAML file are reflected live in your running app with the current application state. The following table lists the Visual Studio and Xamarin.Forms versions that support Hot Reload. Please refer to [this blog](https://dev.to/vijays/xaml-hot-reload-comes-to-xamarin-nf3-temp-slug-4605125) for more details about the Hot Reload option.

![IDE Frameword and VS version](https://thepracticaldev.s3.amazonaws.com/i/dd0q7tg119vky55m0len.png)

**Note:** At .NET Conf 2019, the team announced Xamarin Hot Restart. The Hot Restart option will allow you to rapidly verify the changes you made in the code-behind and resource files. This is achieved by pushing the new assemblies directly into the existing app bundle, instead of redoing a complete build. This is going to be the most welcomed feature by Xamarin.Forms developers. Refer to [this blog](https://devblogs.microsoft.com/xamarin/xamarin-dotnet-conf-2019/) for more details about it, along with statistics showing its performance impact.

## Build-time optimization

Building an application certainly takes a considerable amount of developers’ time, especially when it comes to building Xamarin.Forms for Android projects. There are a few properties that you can use to speed up the build process in Xamarin.Forms application. Refer to [this blog](https://devblogs.microsoft.com/xamarin/optimize-xamarin-android-builds/) for more details about the combination of settings that can be used to optimize build times.

## Continuous integration

Though you can use Hot Reload and build optimization options, at the end of the day, someone must make the build that will be delivered to testers and end-users. We often come across a situation where the build works as expected on our end, but misbehaves on the customer’s end. Continuous integration (CI) is the best solution for these kinds of struggles. Not only for Xamarin.Forms, but for any domain or platform you work with, CI will improve your productivity without a doubt. To help you implement CI in your Xamarin.Forms projects, Visual Studio offers the [App Center](https://appcenter.ms/).

App Center can build the application for every commit you make in your repository, test the application with many virtual devices, and distribute the application to the various collaborators to use or test further. The most useful part of the App Center is it can report many analytical and diagnostic data points, like crash reports, user history over various modules of the application, and more. There are free and paid versions of App Center available. Refer to this [documentation](https://docs.microsoft.com/en-us/appcenter/) for more details.

## Conclusion

The tips I listed in this blog are all from my own experiences, and I hope they will help you too. My colleagues and I invite you to see all our [Xamarin.Forms](https://www.syncfusion.com/xamarin-ui-controls) controls in action by downloading a [free trial](https://www.syncfusion.com/downloads/xamarin). You can also explore our samples available on [Google Play](https://play.google.com/store/apps/details?id=com.syncfusion.samplebrowser) and the [Microsoft Store](https://www.microsoft.com/en-us/p/syncfusion-essential-studio-for-xamarin/9nn069tldzf4). You can learn about the controls’ advanced features in our [documentation](https://help.syncfusion.com/xamarin/).

If you have any questions about these controls, please let us know in the comments below. You can also contact us through our [support forum](https://www.syncfusion.com/forums), [Direct-Trac](https://www.syncfusion.com/support/directtrac/), or [feedback portal](https://www.syncfusion.com/feedback/xamarin-forms). We are happy to assist you!

The post [7 Ways to Boost Your Xamarin Development Productivity](https://www.syncfusion.com/blogs/post/7-ways-to-boost-your-xamarin-development-productivity.aspx) appeared first on [Syncfusion Blogs](https://www.syncfusion.com/blogs).