Titanium Mobile – Beyond the Prototype

Appcelerator’s Titanium Mobile is a powerful toolkit for building cross-platform mobile applications. Using Javascript, which is familiar to many developers, you can build native applications on iOS and Android without learning the intricacies of the native SDKs.

Many developers dive into the product without steeping themselves in Appcelerator’s philosophy, which can be a mistake. Over time (after reading hundreds of Q&A threads, blogposts, API documentation, guides, JIRA reports, and even source code), the developer starts to form a more complete picture of the platform and finds the best ways to structure his code. This guide is intended to jumpstart that process, to help you get from quick-n-dirty prototype to a fully functioning mobile app.

While the potential for Titanium Mobile is tremendous, many users get turned off by some of its failings:

  • Inconsistent API calls (calls may work differently on android and iOS, or even work on one platform and fail on the other)
  • Building stable, cross-platform application navigation (single window or tab group) is decidedly non-trivial, and most people are doing it wrong; when you do it wrong, your app will fail in very strange ways, which may be almost impossible to diagnose. Part of the problem is that documentation on this is somewhat sparse, and fairly deep into the guides, and the other part is that the SDK doesn’t do a good enough job to make this easier — why is it so complex to manage windows with a Tab Group, for example?
  • Inaccurate documentation — Appcelerator hasn’t done a great job keeping their documentation up with the rapidly changing APIs and rapidly evolving best practices
  • Kitchen Sink demo app sets a terrible first example — while this app showcases all the different UI elements, its coding style is not at all in line with best practices; to Appcelerator’s credit, they’ve tried in various places to explain this distinction, but you have to read a lot of documentation before you might come across that. In the real world, developers like to find sample code, start copying and pasting, and they’re off to the races. Do that with Kitchen Sink, and you’re going to be burned.
  • Outdated forum posts — anything published before October of 2011 is not likely to be of much use with current versions of the SDK (1.8+); unfortunately, the forums serve to perpetuate a lot of the inaccurate concepts and bad coding practices

It takes a few weeks at least to develop solid strategies for Titanium Mobile development. I think that many developers do not make it over this initial learning curve.

A developer builds a quick proof-of-concept app (not using best practices; probably copying and pasting from Kitchen Sink), and then as he tries to build a more complex app, he is plagued by stability problems. Even worse, he may have wanted to build a cross-platform app, but spent all his time testing with the iOS simulator. When he tries his nearly-complete app on android, it crashes and burns dramatically.

It is vital that a Titanium Mobile developer follow best practices as laid out by Appcelerator. If cross-platform is the goal (and it really should be), your app needs to be cross-platform at the core, in the navigation between windows, the controls you build, etc.

This guide speaks to the code structure of applications in Titanium Mobile and it illustrates a large number of “gotchas” that could derail your development. As painful as it may be for a developer to read the manual, I would highly suggest that you read through these articles before embarking on your project. If you don’t follow these best practices, you’re unlikely to get the results you want. You’ll ultimately have to tear apart your code and restructure it anyway, so you might as well spend an hour reading through these articles and learning the fundamentals well.


Tutorial: Building a Ti Mobile App: GrillTime

Leave a Reply

Your email address will not be published. Required fields are marked *