Logo

PhoneGap – A Few Significant Factors to Mull Over

PhoneGap

PhoneGap- the application framework enables the developers in building native mobile applications while leveraging state of the art web development technologies.

The apps are usually natively installed on Android, Blackberry, IOS, windows phone, Firefox OS, Tizen, all leveraging -

  • CSS for styling and layout
  • HTML for user interface
  • JavaScript for dynamism, interaction and interactivity with native-OS functionality

Possibly you know this already; PhoneGap offers you enough flexibility. It supports -

  • Multi-page apps or single page
  • AJAX apps
  • Common frameworks
  • User interface libraries and more

Let’s not deny; no single pattern can cover every developer in every use case. Also there is hardly any one size all approach for this as different apps have different requirements and also developers have different skill sets. There are also a whole lot of permutations and combination to mull over. In this blog post, we will highlight all the aspects that you may need to consider when building a PhoneGap application.

PhoneGap Application Framework

A closer look at the General Architecture

Simply put; there are two distinct approaches to follow when building PhoneGap applications –

  • Single-page apps
  • Multi-page apps

Single Page Apps

Honestly; we usually recommend going with this single-page app architecture. For the uninitiated; in single page apps, all of the application logic exists in the JavaScript. The main index file contains the necessary links to all of the JavaScript files, which are required for the application. When the page loads, the JavaScript typically initializes the application while rendering the HTML for the user interface.

It makes sense to mention here; in normal circumstances however the web view do not unload the main index.html file and if in case of any user input, the data is retrieved from storage and from other user interface changes. This means; the HTML DOM is updated within the index.html file in-memory via the JavaScript. The Single Page approach thus helps you create web apps, which look and feel more like the apps instead of web pages.

It is also relevant mentioning here; you don’t have to reinitialize, once the PhoneGap js library gets initialized.Also; with the single-page architecture there is hardly any chance of missing the in memory resident data.

It also helps you manage the transition of content easily. Yes; you have guessed that right; many development frameworks nowadays leverage this single page approach for building applications.

Multi-Page Apps

On the other hand; the multi-page applications somewhat functions like the traditional web pages. Each “HTML file” or each “page” contains a discrete set of functionality. It works pretty simply. Once the page loads the content is displayed. The user interacts with it and then another page is loaded. All these pages are either loaded from the remote servers or from the local file system.

This typical style of architecture works for many developers but there are a few notable drawbacks to multi page approach.

  • 1st Drawback: There are clear transition pages in between. This may lead to loss of JavaScript in-memory resident data.
  • 2nd Drawback: It requires you to include the PhoneGap JavaScript library in every page.
  • 3rd Drawback: As already briefed; there is not much differentiation between the mobile app and the website. This means if your app looks too much like the mobile website then there is high chance of getting rejected at the app store approval processes. For instance; Apple’s App Store clearly states, “Web Based Designs” will be rejected.

Keep in mind; building successful PhoneGap applications is more than just the client-side architecture as you also need to consider services related to user interface as well. As a matter of fact; this is not particularly about PhoneGap applications but it’s applicable to all mobile apps in general.

Here are a few significant factors to mull over

JavaScript Libraries

It appears that the number of JavaScript libraries increase with each passing day and each is intended to make the development experience hassle free and easier.

You should consider a few important things prior leveraging the existing libraries. A few pros and cons for you to consider -

Pros:
  • JavaScript libraries offer easy and familiar APIs for common tasks
  • Libraries increases the productivity greatly
  • JavaScript libraries can condense logic
  • With the JavaScript library the developer doesn’t have to be an expert in executing the common task
Cons:
  • JavaScript libraries may include cross-platform logic/detection, which adds file size & computational logic for performing a given action
  • JavaScript libraries can have bugs
  • Tracking down bugs is difficult in JavaScript

Frameworks and MVC

The Model-View-Controller frameworks or more precisely the MVC frameworks typically enforce the common coding practices, which help in separating the data from the MVC codebases. However MVC controller frameworks are rather complex, and may require a rather higher degree of programming knowledge.

It also makes sense to mention here that MVC architectures may help you develop a particular codebase that can be optimized for each platform and device classification.

Developers should respect the operating environment of the mobile applications. It also makes sense to mention here; the structuring and streamlining data that your app may needs further helps in streamlining the app’s performance.

The bottom-line

Yes; you have whole lot of options when building the PhoneGap applications. Yes; a whole range of web tools are at your disposal to help you create stunning apps. The more responsive and the faster you can make a quality app, the more your users will love you.