 I just finished reading Boydlee and Trevor‘s new (e)book: Appcelerator Titanium: Patterns and Best Practices.
I 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.forEachinstead offorwherever you can.
- Declare var ln;before usingln = Array.lengthinforso 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 requireby using callbacks instead.
- Always use dpas unit.
 
			
Instead of using the Titanium Studio code formatter, I actually hooked up JS-Beautify to run just before Alloy compiles. This ensures every file is automatically beautified, and forces everyone to use it :)
https://github.com/mcongrove/ChariTi/blob/1.1.1/app/alloy.jmk