Category Archives: Titanium Mobile

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.

Continue reading Titanium Mobile – Beyond the Prototype

Titanium Mobile – Extending Views with CommonJS

When you’re building an intricate user interface with Titanium Mobile, you’ll absolutely want to organize your UI elements into well-designed CommonJS modules. This makes it easy to reuse components throughout your app and even across other apps. It’s also a lot easier for maintainers to deal with it if you organize it well.

Continue reading Titanium Mobile – Extending Views with CommonJS

Titanium Mobile – CommonJS Fundamentals

For many developers, a Titanium mobile project might be their first exposure to serious object-oriented programming in Javascript. They may have even used a framework like jquery or mootools (or if they’re really lucky, qooxdoo — check it out sometime). But most of the time, even if you’re using those frameworks, you don’t have to do a lot of your own class definitions.

It’s critical in Titanium Mobile that you follow best practices in your application design. There are three different methods that have been used by Titanium Mobile developers during its relatively short lifetime. There is really only one you should use at this point; I will cover the others so that you can recognize them when you encounter them online (there are still people using these techniques).

  • multi-context: open a window with the "url" property set to a Javascript file; this results in a new Javascript context being created for the file to run in. DON’T DO THIS!
  • namespacing: create a global variable and add properties to that global variable via modules that you include() into your code. DON’T DO THIS!
  • CommonJS: build modules that are each isolated from the global namespace and explicitly define the interface for that module. DO THIS!

More information on these strategies is found here: http://docs.appcelerator.com/titanium/2.0/index.html#!/guide/Coding_Strategies

All guidance from Appcelerator points to using CommonJS modules. It is the best way to build a robust single-context application that is free from nasty memory management issues.

So how do you structure your modules? I will illustrate a number of different techniques here.

Continue reading Titanium Mobile – CommonJS Fundamentals