Best Practices
From WebOS101
Contents |
Introduction
Here is some collected wisdom from the webOS development community.
Coding
- Use a tool like JSLint or JSure to check your code for typos and other potential coding mistakes
- Pick a coding standard that you are comfortable with and stick with it
- Learn Test Driven Development: Mojo™ Test Framework
Debugging
- To help with debugging, use Mojo.Log.info("%j", object) to log out the contents of an object. This is invaluable to use when getting responses from Mojo service requests to see what actually came back.
- When code isn't working right, wrap it in try/catch blocks. Not all errors will be logged automatically and sometimes errors occur in places you don't expect.
- Debugging on the device is more difficult on the emulator as by default the device doesn't log anything except errors.
- Use the Ares (or Ares stand-alone) logger to easily see your logs without duplicates.
- Use the Ares (or Ares stand-alone) debugger to single-step through your code.
- Use weinre to debug your application's DOM and styling instead of the deprecated Palm Inspector (for usage instructions on Mac OS X, see [1])

