by

Appcelerator Titanium: Patterns and Best Practices

Appcelerator Titanium: Patterns and Best PracticesI just finished reading Boydlee and Trevor‘s new (e)book: Appcelerator Titanium: Patterns and Best Practices.

Want to learn the best practices from Boydlee in person? He will be speaking at the Amsterdam Titanium meetup on April 15th.

This is my take from it:

  • Always place the opening curly bracket on the same line.
  • Use Array.forEach instead of for wherever you can.
  • Declare var ln; before using ln = Array.length in for so the calculation is cached.
  • Use the code formatter in Titanium Studio: Source / Format or Shift-Command-F.
  • Enable JSLint validation in Titanium Studio (3.1): Preferences > Studio > Validation > JSLint Validator.
  • Always at least return; in your functions to prevent JavaScript from returning whatever you did last.
  • Never use anonymous functions as event listeners, since you cannot remove them.
  • Null heavy objects like WebViews and Maps when closing a window to speed up memory release.
  • Re-read the docs on platform-specific resources.
  • Prevent recursive require by using callbacks instead.
  • Always use dp as unit.

Comments are closed.