AppSuite:UI Development Style Guide

Revision as of 15:45, 9 April 2013 by Mattes (talk | contribs) (Created page with "=UI Development Style Guide= There lots of stuff we don't need to talk about because JSHint will bug you! (white space, formatting, undefined variables, globals, etc.) *Inde...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

UI Development Style Guide

There lots of stuff we don't need to talk about because JSHint will bug you! (white space, formatting, undefined variables, globals, etc.)

  • Indentation is 4 spaces*

No tabs! And there's no need for two consecutive empty lines. If possible turn on "show white-spaces" in your editor.

Eclipse seems to have a bug on MacOS that makes the editor really slow when showing white-spaces. However, as long as you configure Eclipse properly to use spaces instead of tabs and remove all trailing white-space on save (yep, there's a flag for that), you can leave that option turned off.

  • Use underscore's high-level functions (e.g. each, filter, map)*

Because it's nice to read and it uses native code if available. For example, iterating an array via .each() is faster than a classic for-loop (in Chrome at least). Don't use jQuery's each (except for DOM nodes). If you need "break" you have to use a classic for-loop.