Hands-On Mobile Development with .NET Core
上QQ阅读APP看书,第一时间看更新

Xamarin versus Xamarin.Forms

Xamarin, as a runtime and framework, provides developers with all the necessary tools to create cross-platform applications. In this quest, one of the key goals is to create a code base with a minimal amount of resources and time; another is to decrease the maintenance costs of the project. This is where Xamarin.Forms comes into the picture.

As we explained previously, by using the Xamarin classic approach, developers can create native applications. In this approach, we aren't really worried about creating a cross-platform application since we are creating an application, for all the target platforms using the same development tools and language. The shared components between the target platforms would, in this case, be limited to the business logic (that is, view-models) and the data access layer (models). However, in a modern mobile application, the actual business logic would have been migrated to a service-oriented implementation. The application is generally responsible for executing simple service calls through a gateway API facade on the bundle of downstream microservices, as shown in the following diagram:

In an infrastructure setup similar to this, where each client can benefit from a tailored mobile API gateway, the platform implementations diverge from each other, mostly because of the separate UI layer. Moreover, shared business logic and the data access layer cannot really increase the amount of shared code.

As a general rule of thumb, Xamarin classic applications are advised to be used with applications with key features that are dependent on the platform they are running on (peripheral APIs, intrinsic UI components, performance requirements, and so on). However, for a general purpose mobile application with a cloud-base service backend, it might be a better option to use Xamarin.Forms.

The Xamarin.Forms framework aims to standardize the UI implementation process while preserving the nativity of the application on multiple platforms. In essence, applications that are created with Xamarin.Forms are rendered with native UI elements from the target platform. As a matter of fact, once compiled and linked, a Xamarin application is not any different than a Xamarin.Forms application for any given target platform.