Interview questions for Xamarin
1) What is Xamarin?
Xamarin is a company that builds the software. The main operation of Xamarin is to build mobile apps that work on cross-platforms. It is used to build the UI for Android, iOS, and Windows operating system. Xamarin application shares the codebase. Xamarin’s feature is similar to the native application. A developer can download the Xamarin tools in Visual Studio.
2. What are the various flavors of Xamarin Applications that can be made?
Xamarin allows two different ways of creating applications, based on the amount of code reusability and customization:
• The first approach is the Traditional Native Approach wherein platform-specific apps using Xamarin.iOSiOS and Xamarin.Android can be made. This way of creating apps is generally used when there is a lot of customization specific to the platform is required as it allows direct access to platform-specific APIs. Xamarin.iOS is used for iOS applications and Xamarin.Android is used to create Android applications.
• The second approach is creating apps through Xamarin.Forms approach. Xamarin.Forms are used when there is a possibility of reuse of a lot of platform-independent code and the focus is less on custom UI. The platform-independent code is separated and kept in Shared Project or PCL or .NET Standard Library and Platform Specific projects consume this common code by including it.
3. What are the disadvantages of Xamarin Development?
Disadvantages of Xamarin app Development are:
o The development of user interfaces in Xamarin is Time-Consuming.
o The apps created in Xamarin have a large file size. These apps are mostly between the 3 MB to 15 MB in size in the store.
o Even apps share the code across the platform, but there is also a need for the developer to create the linkage in the OS, which is difficult for the user.
4. Explain how to use shared projects in Xamarin?
Shared Projects are the usual .NET application projects that contain code files and assets. Shared Projects are meant to be included in other projects and help in code reuse. It is a code level sharing technique.
A cross-platform application that supports iOS, Android, and Windows would require an application project for each platform and a separate Shared Project for the code common to all.
So, if you are creating a cross-platform app for Android, iOS, and Windows, you will usually have the following projects
• Shared Project – the Shared Project that contains the code which is common for all platforms viz iOS, UWP, Android
• AppAndroid – the Xamarin.Android project that specifically calls the underlying .NET APIs exposed for Android
• AppiOS – Xamarin.iOS application project that specifically calls the underlying .NET APIs exposed for iOS
• AppWindows – Windows application project that utilizes exposed Windows APIs and specific to UWP (Universal Windows Platform)
A Shared Project is not directly compiled. In other words, no DLL file is produced in the compilation process. Instead, the files are compiled into the same DLL as the project that references it. This way, it is possible to write blocks of platform-specific code in the Shared Project that will only be compiled by the specific platform.
The advantages of using this technique are:
• Allows you to share common code across multiple projects.
• The shared code can be branched based on the platform using compiler directives (eg. using #if __ANDROID__ or #if __IOS__)
• Application projects can include platform-specific references that the shared code can utilize
They do not produce any output assembly of their own. Hence, not used for sharing and distributing to other developers
5. What are the development approaches in Xamarin?
Xamarin has two approaches for app development. These are
1. Xamarin.Forms: Forms are the choices for the developers who want to create one application for all the separate mobile platforms, which are Windows, iOS, and Android.
2. Xamarin Native: This approach is used in those scenarios when we want to create a separate version of the same App for different platforms. Developers can use Xamarin.iOS, Xamarin.Android and Xamarin.Windows libraries to create the applications for each particular platform.
6. What are Effects and when should they be used?
Effects, like Custom Renderers, allow a developer to customize controls for a specific platform. Effects are preferred over Custom Renderers when small styling changes are required instead of a complete layout or behavior change. Custom Effects are created for platform-specific projects by extending the base class PlatformEffect. Once created, they can be attached to the control it is meant for.
Effects don’t have any type related information about the control they are attached to and hence if they are specified with a wrong control they should gracefully degrade.
Effects are reusable and can be parameterised to extend its reusability.
7. What is Xamarin Insights?
Xamarin insight is a tool that allowed the developers to identify and track the issue with the apps in real-time. We can also use this for the monitoring system to report the problems. Xamarin introduced Xamarin Insight in October 2014. However, it was closed on March 31, 2016. In today’s time, developers can believe in Visual Studio App Center for the same functionality that is provided by the Xamarin Insights.
8. What do you mean by Data binding in Xamarin?
Data binding is used to automatically provide synchronization between the user interface and the data source. When data binding is enabled, the UI elements automatically reflect the data or business model changes and vice versa.
9. What are the Different Types of data binding Models available in Xamarin?
The following are different types of data binding models in xamarin.
• One Way: Source changes are reflected in the target.
• One Way to the source: Target changes are reflected in the source.
• Two Way: changes in source affects the target and vice versa.
10. What is Xamarin.Forms?
Xamarin.Forms is a framework which is used to build the user interface in the mobile application. In the same codebase, developers have to write the UI separately for each platform. This is time consuming and difficult process. Xamarin.Forms allows the developer to create just one UI which can be used across all platforms like Android, iOS, and Windows.