Book Image

Appcelerator Titanium: Patterns and Best Practices

By : Boydlee Pollentine , Trevor Ward
Book Image

Appcelerator Titanium: Patterns and Best Practices

By: Boydlee Pollentine , Trevor Ward

Overview of this book

<p>Titanium Mobile has quickly become the platform of choice for many mobile developers and is growing and changing at a rapid rate. From the implementation of CommonJS,&nbsp; MVC design patterns and more, the last year in Titanium development has been a rollercoaster of change for the better. With this knowledge at your disposal you’ll be creating top quality, highly capable and stable apps in no time.<br /><br />This book shows you exactly how to implement all the latest Titanium Mobile best practices into your apps, from a thorough explanation of CommonJS with plenty of examples, through to structuring a complete MVC style codebase. With advanced topics such as implementing patterns and utilizing ACS, through to a thorough investigation of CommonJS and prototype, this book will take you from Titanium Novice to Titanium Ninja in no time!<br /><br />"Appcelerator Titanium: Patterns and Best Practices" starts off with some explanations on JavaScript practices and advanced topics, before getting stuck into the new CommonJS pattern and using that to implement MVC-style architectures for your application. It continues in a practical, hands on manner, explaining how to perform cross device layouts with different techniques, and how to implement SQL alternatives such as JSONDB.<br /><br />The book discusses some of the major advanced JavaScript topics, such as prototype and micro optimizations, before leading the developer into a thorough explanation of the CommonJS pattern, MVC implementation and advanced topics such as SQL alternatives and implementing designs for cross device layouts.</p>
Table of Contents (12 chapters)

The difference between DPs and PXs


You may have noticed that many Titanium examples on the web will often use px (pixel) values, whereas others use dp (density-independent pixels ) instead. There is a significant difference between the two values which is important to understand whenever putting together a cross-platform application.

  • px: This unit corresponds to the actual pixels on the screen. In the case of the iPhone, for example, this value is 320 x 480 px.

  • dp: This unit corresponds to the physical density of the screen. The scale of dips to pixels is not always proportionate between devices, and is definitely not proportionate between platforms. On iOS, 1 px equals 2 dp. This is how iOS retina images work, by always being twice the density of the equivalent area in pixels.

On iOS, you can use either pixels or dps—they are treated in the same way. To implement both normal and retina images on the iPhone or iPad is a simple case of creating two separate images—one in the native pixel resolution...