You are previewing Appcelerator Titanium: Patterns and Best Practices.
O'Reilly logo
Appcelerator Titanium: Patterns and Best Practices

Book Description

Take your Titanium development experience to the next level, and build your Titanium knowledge on CommonJS structuring, MVC model implementation, memory management and much more

  • Full step-by-step approach to help structure your apps in an MVC style that will make them more maintainable, easier to code and more stable

  • Learn best practices and optimizations both related directly to JavaScript and Titanium itself

  • Learn solutions to create cross-compatible layouts that work across both Android and the iPhone and utilize the new Appcelerator Cloud Services to bring your apps to the market faster than every before

In Detail

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, Cloud Services, 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.

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!

"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, how to implement SQL alternatives such as JSONDB, and how to get the best out of the new Appcelerator Cloud Services.

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. It completes with a full overview of the new Appcelerator Cloud Services and how to implement them in your own Titanium Mobile applications.

Table of Contents

  1. Appcelerator Titanium: Patterns and Best Practices
    1. Table of Contents
    2. Appcelerator Titanium: Patterns and Best Practices
    3. Credits
    4. About the Authors
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Understanding JavaScript Patterns
      1. It's all object(ive)
      2. Understanding scope and the global object
        1. The global object
      3. Code structure and formatting
        1. Use semicolons and curly brackets
        2. eval is evil
        3. The curly bracket position
        4. Not all operators are created equal
        5. Formatting, commenting, and naming conventions
      4. Prototype
      5. Micro optimizations
        1. Declaring variables outside the for statements
        2. Using forEach instead of for loop
        3. Using shortcuts for simple if statements
      6. Summary
    9. 2. Titanium Best Practices
      1. CommonJS
      2. Code formatting
      3. Code validation
      4. Comment meaningfully
      5. Do not pollute the global object
      6. JavaScript instance
      7. CommonJS modules
      8. CommonJS best practices
      9. Managing memory
      10. Summary
    10. 3. Building an Application Using CommonJS and the MVC Pattern
      1. Standards
      2. Frameworks
      3. The architecture
        1. CommonJS
      4. The bootstrap
      5. Multilingual
      6. Directory structure
        1. Android
        2. iPhone and iPad
        3. Control
        4. Model
          1. Services
          2. Data
        5. UI
        6. Tools
      7. Naming
      8. The application
      9. The controller
      10. Tools (helpers)
      11. CommonJS require
      12. Callbacks
      13. Model
      14. UI
        1. The layout module
        2. The custom menu
        3. Common elements
        4. Windows
      15. The controller updated
      16. Fail gracefully
      17. Summary
    11. 4. Cross-platform Design Methods
      1. The difference between DPs and PXs
      2. Understanding Ti.UI.SIZE and Ti.UI.FILL
        1. Ti.UI.SIZE
        2. Ti.UI.FILL
      3. Choosing a cross-platform layout method
        1. Using Ti.Platform.osname statements
        2. Developing with separate UI files
        3. Importing component styles from external files
        4. Building a JavaScript stylesheet CommonJS module
        5. Using the Stylesheet CommonJS module in your app
        6. Extending the Stylesheet module for page-specific styles
      4. Summary
    12. 5. Using JSONDB as an Alternative to SQLite
      1. Installing the JSONDB module
        1. Setting up JSONDB
          1. Creating a JSONDB CommonJS module
      2. Using JSONDB queries
      3. Summary
    13. Index