Exploring cross-platform development
The term cross-platform application development refers to the process of creating a software application that can run on multiple operating systems. In this book, we will not try to answer the question of why, but how to develop cross-platform applications – more specifically, we will try to create a cross-platform application using the toolset provided by Microsoft and .NET Core.
Before we start talking about .NET Core, let's take a look at the process of developing an application for multiple platforms. Faced with the cross-platform requirement, the product team can choose multiple paths that will lead the developers through different application life cycles.
Throughout this book, we will have hypothetical user stories defined for various scenarios. We will start with an overall user story that underlines the importance of .NET Core:
In order to meet these demands, we can choose to implement the application in several different ways:
- Fully native applications
- Hybrid applications
- Cross-platform
Let's take a look at each of these methods.
Developing fully native applications
Following this path would create probably the most performant application, with increased accessibility to platform APIs for developers. However, the development team for this type of development would require a wider range of skills so that the same application can be created on multiple platforms. Development on multiple platforms would also increase the developer hours that need to be invested in the application.
Considering the scenario presented in the previous section, we would potentially need to develop the client application in Cocoa and CocoaTouch (macOS and iOS), Java (Android), .NET (Windows), and C++ (Linux), and finally build a web service infrastructure using another development platform of our choice. In other words, this approach is, in fact, implementing a multi-platform application rather than a cross-platform one.
Hybrid applications
Native hosted web applications (also known as hybrid applications) are another popular choice for (especially mobile) developers. In this architecture, a responsive web application would be hosted on a thin native harness on the target platform. The native web container would also be responsible for providing access to the web runtime on native platform APIs. These hybrid applications wouldn't even need to be packaged as application packages, but as Progressive Web Apps (PWAs) so that users can access them directly from their web browsers. While the development resources are used more efficiently than in the native cross-platform framework approach, this type of application is generally prone to performance issues.
In reference to the business requirements at hand, we would probably develop a web service layer and a small Single - Page Application (SPA), part of which is packaged as a hybrid application.
Native cross-platform frameworks
Development platforms such as React Native, Xamarin, and .NET Core provide the much-required abstraction for the target platforms, so that development can be done using one framework and one development kit for multiple runtimes. In other words, developers can still use the APIs provided by the native platform (for example, the Android or iOS SDK), but development is executed using a single language and framework. This approach not only decreases development resources, but also saves you from the burden of managing multiple source repositories for multiple platforms. This way, the same source is used to create multiple application heads.
For instance, using .NET Core, the development team can implement all target platforms using the same development suite, thereby creating multiple client applications for each target platform, as well as the web service infrastructure.
In a cross-platform implementation, architecturally speaking, the application is made up of three distinct tiers:
- Application model (the implementation layer for the consumer application)
- Framework (the toolset available for developers)
- Platform abstraction (the harness or runtime to host the application)
In this context, we, in essence, are in pursuit of creating a platform-agnostic application layer that will be catered for on a platform abstraction layer. The platform abstraction layer, whether we are dealing with a native web host or a native cross-platform framework, is responsible for providing the bridge between the single application implementation and the polymorphic runtime component.
.NET Core and Mono provide the runtime, while .NET Standard provides the framework abstraction, which means that cross-platform applications can be implemented and distributed on multiple platforms. Using Xamarin with the .NET Standard framework on mobile applications and .NET Core on the web infrastructure, sophisticated cloud-supported native mobile applications can be created.
As you can easily observe, native cross-platform frameworks offer the optimal compromise between development costs, performance, and the nativeness of the target application, providing developers with an ideal option for creating applications for multiple platforms. From this perspective, .NET (Core) and Xamarin, which together evolved into a cross-platform framework and runtime, has become one of the most prominent development platforms for mobile applications.
We have discussed different ways to implement cross - platform applications and identified the pros and cons of these methodologies. We can now start exploring the .NET ecosystem and cross-platform toolset.