|
Comments
|
Features Living on the Edge of Mobile Development
Overview and experience with Sencha Touch, YUI Test and PhoneGap
By: Mike Jacobs
Mar. 17, 2011 03:00 PM
Which mobile device should I target for my application? That's one of the first questions you need to answer as a mobile developer. You might select the device based on personal preference or what looks cool today. The problem is that mobile technology choices are diverse and evolving quickly. The tools and languages used to develop native applications vary wildly and you probably cannot afford to learn them all. Chances are you want to find a way to replicate your application across multiple devices while minimizing your investment. How can that be done? Hybrid Is More than a Green Decision The combination of familiar web technologies with minimal native code enables you to develop your application once and deploy to a variety of mobile devices. Now you might be thinking 'Are these web standards finalized?' and the answer would be no. However, the HTML rendering engines used in most mobile devices have been implementing the features as the standards are published. Javascript libraries are wrapping these features and compensating for device differences and standards evolution so your application does not need to. There are several libraries under development but I elected to use Sencha Touch.
Figure 1 - This diagram depicts the major differences between mulitple native and hybrid application development Sencha Touch Is My Cup of Tea
Figure 2 - Example Sencha Touch application running on Apple iPhones My First Sips of Sencha I found it quite easy to define enities and storage objects with the data integration features. The storage objects were extensible enough to add custom search features. The user interface elements often took some experimentation and reverse engineering to fill in the gaps of light documentation. I had to become familiar with the inspection and debugging features of Chrome and Safari to ultimately answer many questions. There are still a few inconsistencies in how user interface element templates are used but overall, the library is quite complete. One of the most powerful user interface features is the branding support. The branding support in Sencha uses Syntactically Awesome Stylesheets (SASS). SASS is a scripting language that describes how to generate cascading stylesheets. Need to change your corporate color across all user interface elements? Change it in one place and regenerate your native look-and-feel stylesheet. Sencha Touch ships with a full library of SASS scripts that you can easily extend to meet your branding needs. This approach also encodes images into the stylesheet to reduce the number of files to deploy. I was able to extend the SASS to specify branding color selections, omit unused user interface elements and specify the needed icons. Sencha provides best practice advice for project organization and the use of the MVC support. Part of the project organization is for unit testing. It is your choice how to test your JavaScript, but the best practice within our organization for other technologies is to use one of the xUnit libraries and include regression testing as part of continuous integration. I did an informal survey within our development group and found that Javascript is an exception. Since the bulk of a hybrid application is JavaScript, I found it necessary to evaluate and select a suitable unit testing approach.
Figure 3 - You can also write applications for the Apple iPad This is Only a Test
I looked at two dozen different options and selected the YUI Test Standalone Library. This is a project to separate the Test module from the popular Yahoo! UI framework. It is currently released as a beta and appears to be slated for a first quarter 2011 release. Running unit tests requires the use of a desktop browser. Javascript is used to set up the test environment including the suites and tests. I found the suites and tests to be very similar to JUnit tests. Several examples are included and enabled me to create a regression suite with a nice summary report like this:
Figure 4 - A unit testing console for displaying progress and results Manually reviewing unit test results should not be included in a continuous integration development environment. The YUI Test Standalone library includes integration with Selenium Remote Control (RC) to automate the regression test. Selenium RC is a test server that controls browser sessions for testing your JavaScript. The YUI Test Selenium driver enables a build script to:
All of these tasks are done via the Java-based driver included in YUI Test Standalone and can be included as part of a build such as Ant. The coverage report is conditional on a earlier instrumentation step (not shown). The YUI Test Standalone library includes a Java-based instrumentation utility that creates instrumented Javascript proxies of the files targeted for coverage measurement. The coverage report step above depends on the instrumented proxies to creat LCOV-based coverage reports. These coverage reports include a very nice report of line and function coverage including a line by line color coding of the coverage of the source. Going Native PhoneGap fills the technology gap between JavaScript and the native mobile device. It provides JavaScript APIs to underlying native function such as:
PhoneGap also provides console integration with desktop debuggers, support for six platforms and integrated development environment (IDE) project templates. You must have your target platform SDK installed to use PhoneGap. Since my project is targeting Apple iOS, that means a Mac running the Xcode IDE and the iOS SDK. After downloading and installing the IDE, SDK and PhoneGap, a new project template was available. I created a new PhoneGap project and the template created all the native programs, build targets and default properties and images for me. I copied the application build results into the Xcode project, pressed Build and Run and the application was running in the phone simulator. It was that simple. No Objective-C to learn or write with less than a day from install to running. Gaps with PhoneGap
Live Long and Provision There are bound to be changes in the available libraries and supported devices in the coming months. Sencha Touch and PhoneGap is a powerful and easy to use combination that is ready now. Disclaimers
References
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
|||||||||||||||||||||||||||