Skip to Main Content
Mobile Development with C#
book

Mobile Development with C#

by Greg Shackles
May 2012
Intermediate to advanced content levelIntermediate to advanced
174 pages
4h 21m
English
O'Reilly Media, Inc.
Content preview from Mobile Development with C#

Chapter 3. Code Sharing Techniques

In the last chapter, you built simple applications for iOS, Android, and Windows Phone. Even though each provided identical functionality, they were implemented completely independently of one another. This works fine for a simple application with one button and two screens, but is certainly not ideal for real world applications.

As mentioned in Chapter 1, one major benefit of the .NET approach is being able to share a lot of your non-UI code across all platforms. At first, you might think that almost all behavior in most applications is tied to the user interface in one way or another, which would make it very difficult to share any code across platforms. While this may seem true at a higher level, if you dig a little deeper, you’ll find it is often not the case.

For example, consider an application that accesses a web service to download its data in XML format, and then transforms that XML into some model classes that the application can use. All of this code is actually independent of the presentation layer and can therefore be shared across each platform (see Figure 3-1). You only need to write the code for the web service client, XML processing and model classes once, but get to reuse them everywhere.

It’s easy to see how this can apply to many other classes of functionality as well, such as libraries that perform calculations, process data, and process data. In many cases, you will find that the code that can be shared is often the real core ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mobile Development with .NET - Second Edition

Mobile Development with .NET - Second Edition

Can Bilgin
Professional Cross-Platform Mobile Development in C#

Professional Cross-Platform Mobile Development in C#

Scott Olson, John Hunter, Ben Horgen, Kenny Goers

Publisher Resources

ISBN: 9781449338282Supplemental ContentErrata Page