The Power of Cross-Platform Code Bases


  • Justin Wiseman
  • Viewpoint
  • October 12, 2016

In today’s world, new technology is released every day to meet and create new expectations from end users. This technology includes both physical devices and new ways to interact with those devices. Devices come in all shapes and sizes, whether it is a mobile device that runs Android or iOS, or if it is a desktop that runs the latest Windows or Mac OS. No matter the form factor, people need access to the same applications across all platforms, without jumping through all of the hoops of different versions of the business applications, in order to stay connected and effective in daily tasks.

So what solutions are available for cross-platform applications?

  • Connector.

    Option 1

    We can build a native application for every platform, this would require a company to build three different applications to support Android, iOS and Windows, then also maintain the three different code bases. This also would require your team of developers to be Android developers knowing the Android SDK, Apple developers using Xcode, etc.

  • Connector.

    Option 2

    One of the most common ways to meet this criteria, is to build a web application. This is probably the simplest solution going forward, but would not provide its users the flexibility of having a local app for ease of use on their own device. There are ways to make the application available offline in this option, but again would require the user to use their web browser to access it every time.

  • Connector.

    Option 3

    The one we will be looking at in this article, is building a cross-platform application that can be built/packaged to run within the web, as well as, locally within multiple devices. This option can provide the application developers the option of developing a single code base that can be packaged in a way for platforms to digest it like a native application.

While all of these options have both advantages and disadvantages, we found that cross-platform code bases can be an effective solution for many of our clients.

Defining the Technology

Cross-platform software is a software that is supported on multiple computing platforms, and platforms can be defined by different hardware and/or operating systems.

There is a breadth of cross-platform frameworks available today, some more notable frameworks include, Cordova (Apache), ionic and PhoneGap (Adobe). These frameworks are designed to package CSS, HTML and JavaScript into individual applications that can be installed on different mobile OS platforms such as Android and iOS, while using the same HTML, CSS, and JavaScript to create a web application that is available to all web browsers, including desktop browsers.

Each framework continues to build a growing library of plugins that allow for developers to further extend software by leveraging different device APIs, as an example to access local device storage/file structure or to access hardware such as a camera. These plugins enable applications built using these cross-platform frameworks to behave as if they were developed the same as native applications.
Now that we have a brief understanding of the framework, let’s jump into why taking this approach for developing cross platform applications would be so beneficial, and why some may be resistant to taking this approach.

Pros vs. Cons

Pros

A few of the larger arguments for developing on top of cross-platform frameworks are:

Maintain a Single Code Base

A single code base can be used to produce packages that are specific to a single platform, such as .apk for Andriod, .ipa for iOS, etc. This helps not only with distribution of the application, but also helps reduce the cost of developing an app for every platform and the maintenance cost associated to bug fixes and application enhancements.

For example, a company that has a native application developed for multiple platforms, each with their own repository, i.e. Android SDK, Xcode, and Visual Studio for Windows phone, developers would have to develop new features within each application separately, and yes concepts and goals would be the same, but the code needed for the feature could be completely different within each platform.

Whereas leveraging a single code base that can be packaged and distributed to multiple platforms, only requires the developers to build the new feature once.

Leverage the Current Pool of Web Developers

What a cross-platform development also brings to the table that is not always recognized but is one of the key strengths, is who it brings to the table. Because frameworks built on top of many platforms leverage JavaScript, CSS, and HTML, now any web developer can start building applications for multiple platforms outside of just standard web applications.

The benefit also extends to Quality Assurance teams that are building test automation scripts for the application, creating a single automation code base, with minor platform specific code for native UI objects.

Before the concept of frameworks like Cordova, a specialized developer would be needed to build applications on different platforms, such as an Android developer for an Android version of the application then possibly another iOS developer for iOS version of the application.

Now a developer can have a basic background in web development, and be able to build an application for every supported platform, Andriod, iOS, Windows Phone, etc.

Utilize Enhancements of HTML5

The fact that the applications built on a cross-platform framework utilize HTML, they can begin to leverage the new standards of HTML5, such as WebSockets for full-duplex communication. HTML5 feature list continues to grow over time and building applications on top of a framework that supports HTML5, will allow the application to continue to utilize the cutting edge web technology.

Data Synchronization

While the world is becoming more and more of a connected space, we still have areas of that are not connected. Creating an application using a hybrid platform framework allows your users to continue off line then sync instantly once you come back on-line. While this is available for native applications to leverage as well, the syncing back to a central location, i.e. Web Server, can be a bit trickier to do within a native app.

Benefit from Community Plugin Development

Lastly, with open source platforms like Cordova, often new plugins are developed rapidly to expand its capability. These plugins include expanding device hardware interactions, such as access to the devices camera, location services, Bluetooth, etc. These will trigger the devices security policies around asking users to grant permission to the hardware, but after permission is granted, the application can interact with the local hardware seamlessly, as if it were a native application.

Also grants access to analytic tools like Universal Analytics, aka Google Analytics, for gathering usage data around your application. This helps you develop tools that make the most sense to all of your users, and to make sure you are delivering what the user expects.

Understanding the reason for taking a certain approach is great, one must also evaluate the reasons against the approach to make an educated decision when building a cross-platform application.

Cons

A couple arguments for not developing on top of a hybrid platform are:

Always a Half Step Behind for New Native Hooks

While the plugins for these hybrid frameworks continue to grow, there is a limit to the number of hooks into the native operating system. Which limits what an application built using PhoneGap or Cordova as access to until a new plugin is developed. This allows native applications to have a leg up for a short amount of time, but new plugins, especially for high usage features and hardware, do not take long before someone creates one.

Operating System Version Support

Platform support can also be tricky when building applications that span multiple platforms, often times the operating systems that we are trying to support contain multiple versions within themselves that require modifications to the applications code. This is an ongoing battle for developers whether an application is cross platform or not, but one that cannot be ignored.

The ability to support older versions of an OS could require a change to the native code base of the application once the application is package, or could require developing a native application by itself depending on how far back in the version tree you would like to go.

Most of the recent OS versions have good support for HTML and CSS3, so as long as you do not need to support legacy operating systems you should be alright.

Possible Heavy Computation Performance Hit

Lastly, many say that there is more overhead for an application when the platform has to support JavaScript, when compared to processing the native language, but it would not be noticed by the end user unless you were trying to do some heavy computations behind the scenes.

Conclusion

As you can see there are many trade-offs’ to consider when choosing the appropriate architecture and associated frameworks. Through our experience, we would recommend anyone developing an application for any mobile platform spend some time considering a cross-platform framework for their next project. Even if a project starts by supporting a single mobile platform, taking the approach of using a cross-platform framework allows the flexibility to expand to other platforms at a very low cost.

I also recommend on trying it out yourself, many of the platforms mentioned have a large community to help you get started.

 
Justin Wiseman is the Manager for Product Analysis & Design and a leader of ATG’s Software & Quality Solutions (SQS) team. Justin has Bachelor of Science degrees in Computer Science and Math, and a Masters in Business Administration. He has been employed at ATG since 2013.