Click here to close now.

Welcome!

Java Authors: Carmen Gonzalez, Liz McMillan, Trevor Parsons, Elizabeth White, Pat Romanski

Related Topics: Java, Wireless, iPhone

Java: Article

Living on the Edge of Mobile Development

Overview and experience with Sencha Touch, YUI Test and PhoneGap

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
We are all familiar with the idea of hybrid cars and trucks. These vehicles typically combine petroleum and electric technologies to improve efficiency, reducing your carbon footprint.  You can take a hybrid approach for your mobile application by combining multiple technologies to improve your development efficiency, reducing your expenses.  The hybrid approach combines minimal device-specific native code with your application developed with HTML5, CSS3 and JavaScript.  Development of native code is painless through the use of several libraries and tools.  HTML5 provides the underlying capability for storage, drag and drop, timed media playback, and others.  CSS3 dramatically improves the presentation of web technologies enabling a native look-and-feel for mobile applications. JavaScript allows you to use your existing web skills to implement the application.  All of these technologies run within a compatible desktop browser allowing you to develop and test your application without deploying to a device.

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
The Sencha company logo is a green leaf, presumably because sencha is a Japanese whole leaf green tea.  I am an ardent coffee drinker but I really like this tea.  Sencha is perhaps best known for their Ext JS and Ext GWT libraries.  Sencha Touch is their latest library released late in 2010.  There are several similar libraries in various stages of development, but Sencha was one of the first to market and I am working on commercial products that depend on released libraries.  The first release includes support for Android and Apple iOS devices.  Reading the tea leaves promises future support for Blackberry 6 and Blackberry Torch.  The library is open source and supports a dual license approach making it appropriate for commercial use.  The library includes:

  • Robust data integration including access to AJAX, JSONP, or YQL and local storage
  • Large library of user interface elements many of which automatically bind to the data objects
  • Advanced native look-and-feel styling, animation and branding capabilities
  • Model, View, Controller (MVC) support to put it all together

Figure 2 - Example Sencha Touch application running on Apple iPhones

My First Sips of Sencha
I started using Sench Touch in the Summer of 2010 while it was in beta.  I had the typical beta experience of incomplete documentation, a few bugs and changing API.  Over the frequent updates, the documentation improved and examples were updated to align with the latest API.  Throughout the beta and after the production release, I worked on my application.  My application successfully used local storage, tree and carousal navigation, animated transitions, custom search features and selective user updates to content.  The plan is to deploy on Apple iOS devices first with the need for possibly many different branding themes.

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
A robust JavaScript unit testing library should include support for:

  • Continuous integration
  • Multiple browser testing
  • Event testing
  • Mock objects
  • Organization of tests (e.g. suites)
  • Code coverage reports

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:

  1. Start the Selenium RC server
  2. Specify the regression test HTML files
  3. Specify the browsers to run the regression
  4. Run the tests
  5. Collect and report the success or failure of the tests
  6. Optionally create coverage reports
  7. Shutdown the Selenium RC server

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
Up to this point, all development and testing has been done on a desktop running Chrome or Safari.  This has enabled a fast turn around in development and the possible use of browser-based web interface testing automation by a quality assurance group.  This is not to say that all testing can be done on the desktop.  Ultimately, device testing is needed and should be done early and often.  How can we get our HTML, CSS and Javascript to run natively on a mobile device?  The hybrid approach we introduced above would have us write a small program in the target technology that wraps and invokes the application.  Luckily, there are libraries and tools that make this painless.  PhoneGap is the option selected for this project.

PhoneGap fills the technology gap between JavaScript and the native mobile device. It provides JavaScript APIs to underlying native function such as:

  • Accelerometer
  • Camera
  • Compass
  • Contacts
  • Geolocation
  • Media
  • Storage
  • Others

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
Despite the trivial effort to get the application running on the simulator, there were three minor gaps to address:

  • The default target is iPhones.  This means the application would start up and run on an iPad with the dimensions of a phone (with the 2x option).  Sencha Touch reported the platform as a phone even when running on the actual iPad device.  Ideally, the default would be what Apple calls a Universal App that runs on all devices and adjusts itself when running.  After some research, I found that the solution was few mouse clicks away within Xcode.
  • Orientation changes did not work.  A Sencha Touch application can change the way it looks based on the orientation of the device.  PhoneGap always reported the device orientation as portrait (0 degrees) even though Sencha Touch correctly reported the current orientation.  The solution was a minor hack to monitor for the window resize event and inform Sencha Touch to do the right thing.
  • Certain text was rendered as a link.  Clicking on the link offered to add or update a contact.  What was that all about?  It turns out the default web view component in the iOS SDK attempts to find phone number and e-mail addresses and automatically makes them links to the appropriate app like contacts.  Pretty cool if you want that behavior but does 001-999.9 look like a phone number?  The solution was to add one line of Objective-C code in the PhoneGap generated code to turn this behavior off.

Live Long and Provision
In order to get your application running on an actual device you must go through a complex process Apple calls provisioning.  There is a nice step by step procedure to get you through it all available on the Apple developer site.  Now that I have my Sencha Touch application running on an iPad I see that performance work is needed.  Now that automated build and test process is going to pay off.  It is clear to me that a robust development cycle with this technology is possible and practical.

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

  • Opinions expressed in this article are those solely of the author and do not reflect those of my employer.
  • iPhone image Courtesy of Apple
  • Sencha Touch application images used with permission
  • The Android logo is reproduced from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

References

More Stories By Mike Jacobs

Mike Jacobs is technology architect and Technology Fellow focused on using technology to improve health care.

@ThingsExpo Stories
Dave will share his insights on how Internet of Things for Enterprises are transforming and making more productive and efficient operations and maintenance (O&M) procedures in the cleantech industry and beyond. Speaker Bio: Dave Landa is chief operating officer of Cybozu Corp (kintone US). Based in the San Francisco Bay Area, Dave has been on the forefront of the Cloud revolution driving strategic business development on the executive teams of multiple leading Software as a Services (SaaS) application providers dating back to 2004. Cybozu's kintone.com is a leading global BYOA (Build Your O...
Health care systems across the globe are under enormous strain, as facilities reach capacity and costs continue to rise. M2M and the Internet of Things have the potential to transform the industry through connected health solutions that can make care more efficient while reducing costs. In fact, Vodafone's annual M2M Barometer Report forecasts M2M applications rising to 57 percent in health care and life sciences by 2016. Lively is one of Vodafone's health care partners, whose solutions enable older adults to live independent lives while staying connected to loved ones. M2M will continue to gr...
With IoT exploding, massive data will transform businesses with opportunities to monetize almost anything that can be measured. In this C-Level Roundtable Discussion at @ThingsExpo, Brendan O’Brien, Aria Systems Co-founder and Chief Evangelist, will lead an expert panel of consultants, thought leaders and practitioners who will look at these new monetization trends, discuss the implications, and detail lessons learned from their collective experience. Finally, the panel will point the way forward for enterprises who wish to leverage the resulting complex recurring revenue models, adding valu...
How is unified communications transforming the way businesses operate? In his session at WebRTC Summit, Arvind Rangarajan, Director of Product Marketing at BroadSoft, will discuss how to extend unified communications experience outside the enterprise through WebRTC. He will also review use cases across different industry verticals. Arvind Rangarajan is Director, Product Marketing at BroadSoft. He has over 19 years of experience in the telecommunications industry in various roles such as Software Development, Product Management and Product Marketing, applied across Wireless, Unified Communic...
SYS-CON Events announced today that Vicom Computer Services, Inc., a provider of technology and service solutions, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. They are located at booth #427. Vicom Computer Services, Inc. is a progressive leader in the technology industry for over 30 years. Headquartered in the NY Metropolitan area. Vicom provides products and services based on today’s requirements around Unified Networks, Cloud Computing strategies, Virtualization around Software defined Data Ce...
The 17th International Cloud Expo has announced that its Call for Papers is open. 17th International Cloud Expo, to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, APM, APIs, Microservices, Security, Big Data, Internet of Things, DevOps and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding business opportunity. Submit your speaking proposal today!
What exactly is a cognitive application? In her session at 16th Cloud Expo, Ashley Hathaway, Product Manager at IBM Watson, will look at the services being offered by the IBM Watson Developer Cloud and what that means for developers and Big Data. She'll explore how IBM Watson and its partnerships will continue to grow and help define what it means to be a cognitive service, as well as take a look at the offerings on Bluemix. She will also check out how Watson and the Alchemy API team up to offer disruptive APIs to developers.
The IoT Bootcamp is coming to Cloud Expo | @ThingsExpo on June 9-10 at the Javits Center in New York. Instructor. Registration is now available at http://iotbootcamp.sys-con.com/ Instructor Janakiram MSV previously taught the famously successful Multi-Cloud Bootcamp at Cloud Expo | @ThingsExpo in November in Santa Clara. Now he is expanding the focus to Janakiram is the founder and CTO of Get Cloud Ready Consulting, a niche Cloud Migration and Cloud Operations firm that recently got acquired by Aditi Technologies. He is a Microsoft Regional Director for Hyderabad, India, and one of the f...
SYS-CON Events announced today that SoftLayer, an IBM company, has been named “Gold Sponsor” of SYS-CON's 16th International Cloud Expo®, which will take place June 9-11, 2015 at the Javits Center in New York City, NY, and the 17th International Cloud Expo®, which will take place November 3–5, 2015 at the Santa Clara Convention Center in Santa Clara, CA. SoftLayer operates a global cloud infrastructure platform built for Internet scale. With a global footprint of data centers and network points of presence, SoftLayer provides infrastructure as a service to leading-edge customers ranging from ...
SYS-CON Events announced today that Cisco, the worldwide leader in IT that transforms how people connect, communicate and collaborate, has been named “Gold Sponsor” of SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Cisco makes amazing things happen by connecting the unconnected. Cisco has shaped the future of the Internet by becoming the worldwide leader in transforming how people connect, communicate and collaborate. Cisco and our partners are building the platform for the Internet of Everything by connecting the...
SYS-CON Events announced today that Liaison Technologies, a leading provider of data management and integration cloud services and solutions, has been named "Silver Sponsor" of SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York, NY. Liaison Technologies is a recognized market leader in providing cloud-enabled data integration and data management solutions to break down complex information barriers, enabling enterprises to make smarter decisions, faster.
SYS-CON Events announced today that Windstream, a leading provider of advanced network and cloud communications, has been named “Silver Sponsor” of SYS-CON's 16th International Cloud Expo®, which will take place on June 9–11, 2015, at the Javits Center in New York, NY. Windstream (Nasdaq: WIN), a FORTUNE 500 and S&P 500 company, is a leading provider of advanced network communications, including cloud computing and managed services, to businesses nationwide. The company also offers broadband, phone and digital TV services to consumers primarily in rural areas.
SYS-CON Events announced today that Ciqada will exhibit at SYS-CON's @ThingsExpo, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Ciqada™ makes it easy to connect your products to the Internet. By integrating key components - hardware, servers, dashboards, and mobile apps - into an easy-to-use, configurable system, your products can quickly and securely join the internet of things. With remote monitoring, control, and alert messaging capability, you will meet your customers' needs of tomorrow - today! Ciqada. Let your products take flight. For more inform...
SYS-CON Events announced today that ProfitBricks, the provider of painless cloud infrastructure, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY., and the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. ProfitBricks is the IaaS provider that offers a painless cloud experience for all IT users, with no learning curve. ProfitBricks boasts flexible cloud servers and networking, an integrated Data Center Designer tool f...
SYS-CON Events announced today that Dyn, the worldwide leader in Internet Performance, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Dyn is a cloud-based Internet Performance company. Dyn helps companies monitor, control, and optimize online infrastructure for an exceptional end-user experience. Through a world-class network and unrivaled, objective intelligence into Internet conditions, Dyn ensures traffic gets delivered faster, safer, and more reliably than ever.
SYS-CON Events announced today that GENBAND, a leading developer of real time communications software solutions, has been named “Silver Sponsor” of SYS-CON's WebRTC Summit, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. The GENBAND team will be on hand to demonstrate their newest product, Kandy. Kandy is a communications Platform-as-a-Service (PaaS) that enables companies to seamlessly integrate more human communications into their Web and mobile applications - creating more engaging experiences for their customers and boosting collaboration and productiv...
SYS-CON Events announced today that Open Data Centers (ODC), a carrier-neutral colocation provider, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place June 9-11, 2015, at the Javits Center in New York City, NY. Open Data Centers is a carrier-neutral data center operator in New Jersey and New York City offering alternative connectivity options for carriers, service providers and enterprise customers.
SYS-CON Events announced today that On the Avenue Marketing Group, a sales and marketing firm that utilizes events to market and sell products to consumers, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. On the Avenue Marketing Group (OTA) is a sales and marketing firm that utilizes events to market and sell products to consumers. On behalf of our clients, we attend thousands of fairs, festivals, expos, concerts, conferences, and sporting events annually, helping them reach millions of individuals ...
SYS-CON Events announced today that BroadSoft, the leading global provider of Unified Communications and Collaboration (UCC) services to operators worldwide, has been named “Gold Sponsor” of SYS-CON's WebRTC Summit, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. BroadSoft is the leading provider of software and services that enable mobile, fixed-line and cable service providers to offer Unified Communications over their Internet Protocol networks. The Company’s core communications platform enables the delivery of a range of enterprise and consumer calling...
SYS-CON Events announced today that ActiveState, the leading independent Cloud Foundry and Docker-based PaaS provider, has been named “Silver Sponsor” of SYS-CON's DevOps Summit New York, which will take place June 9-11, 2015, at the Javits Center in New York City, NY. ActiveState believes that enterprises gain a competitive advantage when they are able to quickly create, deploy and efficiently manage software solutions that immediately create business value, but they face many challenges that prevent them from doing so. The Company is uniquely positioned to help address these challenges thro...