Tuesday, April 16, 2013

Book Review: Appcelerator Titanium: Patterns and Best Practices

Authors: Boydlee Pollentine and Trevor Ward

This book targets developers who are already familiar with the Titanium Mobile API and JavaScript programming.  Topics covered span JavaScript programming practices to application architecture.  Each area is discussed at a fairly high level, which makes for an easy read.  The authors do a nice job of offering suggestions that can help developers create well structured applications.  Specific chapters are:

  1. Understanding JavaScript Patterns
  2. Titanium Best Practices
  3. Building and Application Using CommonJS and the MVC Pattern,
  4. Cross Platform Design Methods
  5. Using JSONDB as an Alternative to SQLite

JavaScript variable scope is different from that of most of the strongly typed languages.  Add CommonJS into the mix and you have even more scope considerations.  The first two chapters navigate the developer through object scope, show how to avoid “gotyas” associated with something as simple as placement of a curly brace, and show in general how to write clean JavaScript in CommonJS modules.  The authors also take you into the Titanium Studio environment and show how to enable strict JavaScript validation using JSLint.

The third chapter provides a nice overview of how to structure an application using CommonJS with an MVC pattern.  Changing from namespace applications to CommonJS can be difficult to get your arms around.  Pollentine and Ward do a nice job of laying out specific examples for organizing the different application components, for bootstrapping an MVC application, and for managing interactions across components.  This includes examples of using callback functions, which is  a key technique for developing Titanium Mobile applications.

Chapter 4 is more than just cross platform considerations.  The authors start by reinforcing some of the changes in component sizing introduced in Titanium 2.0.  They also discuss in general how to implement common styling across an entire application.  Then they show methods for overlaying platform specific styling as needed.

The last chapter is an introduction to using JSONDB for persistent data.  It’s presented very nicely within the context of implementing a news reader application.  The authors demonstrate all the standard CRUD operations.  

Overall, I would say this book does a nice job of filling the void between having learned the Titanium Mobile API, and knowing how to structure a production quality application.   I like the way the author’s present their best practices as recommendations, rather than “THIS is how you MUST do it.”  I’d recommend this book for any Titanium Mobile developer.