Book Image

Mobile Development with .NET - Second Edition

By : Can Bilgin
Book Image

Mobile Development with .NET - Second Edition

By: Can Bilgin

Overview of this book

Are you a .NET developer who wishes to develop mobile solutions without delving into the complexities of a mobile development platform? If so, this book is a perfect solution to help you build professional mobile apps without leaving the .NET ecosystem. Mobile Development with .NET will show you how to design, architect, and develop robust mobile applications for multiple platforms, including iOS, Android, and UWP using Xamarin, .NET Core, and Azure. With the help of real-world scenarios, you'll explore different phases of application development using Xamarin, from environment setup, design, and architecture to publishing. Throughout the book, you'll learn how to develop mobile apps using Xamarin and .NET Standard. You'll even be able to implement a web-based backend composed of microservices with .NET Core using various Azure services including, but not limited to, Azure Active Directory, Azure Functions. As you advance, you'll create data stores using popular database technologies such as Cosmos DB and data models such as the relational model and NoSQL. By the end of this mobile application development book, you'll be able to create cross-platform mobile applications that can be deployed as cloud-based PaaS and SaaS.
Table of Contents (25 chapters)
1
Section 1: Understanding .NET
5
Section 2: Xamarin and Xamarin.Forms
9
Section 3: Azure Cloud Services
14
Section 4: Advanced Mobile Development
18
Section 5: Application Life Cycle Management

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:

"I, as a product owner, would like to have my consumer app running on iOS and Android mobile platforms, as well as Windows, Linux, and macOS desktop runtimes, so that I can increase my reach and user base."

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.