DONT’S (AND DO’S)OF TITANIUM DEVELOPMENTBY RICHARD LUSTEMBERG
Titan, TCAD, working with Titanium since 2010
www.theappartisan.nl
TOPICS
• Cross platform development
• General
a. Ti.include
b. Globals
c. Events
d. Memory management
• Write an application for one platform (ie. iOS), finish
it and then expect it to run on another (.ie Android)
• Don’t use the default Android emulator
Don’t:
• Test under all platforms incrementally.
• Step by step implementation and profiling.
• Try using TiShadow simultaneously on several
simulator/devices from different platforms
Do:
Doing as in the two steps above will familiarize you
with the platform subtle and not so subtle
differences
TI.INCLUDE()
• It’s deprecated
• It’s an include (basically a copy & paste), so it loads all code in one go.
• If the code is not modularised, it’ll fill up the global space with variables.
• Unless you intend to create global variables, wrap all
variables using self invoking functions
• If you are going to provide globals, then use a
namespace to avoid variable collisions
When doing stuff on app.js or alloy.js
EVENTS
• Adding listeners the wrong way
• Not removing global listeners
• Sending improper event payloads
• Add event listeners from within another event listener
• Add event listeners after firing the event
Don't:
• Causes memory leaks
• Will trigger application crashes when an event
callback attempts to work on stale or nulled data.
Not removing global events:
• Use callbacks instead of events, unless it becomes
too complex
• Prefer native JavaScript events instead of Ti.App
events
• If using Ti.App events, do not pass complex objects
as event payload (iOS)
Top Related