wiki:Documentation/StyleGuide

Code Style Guide

This page is meant to provide some basic coding practices and style guidelines for developers working on Xinha.

  1. Put the brace associated with a control statement on the next line, indented to the same level as the control statement. Statements within the braces are indented to the next level. (Allman Indent Style)
  1. Don't use tabs. Instead, indent code blocks with two spaces.
  1. Always use semicolons after single lines, function definition and object literals, but not after loops and if-blocks. E.g.,
    var foo = function() 
    {
      alert('foo');  
      var foo = 
      {
        foo1 : 'bar1',
        foo2 : 'bar2'
      };
      var bar = 
      [
        'foo',
        'bar'
      ];
      for (var i=0;i<10;i++)
      {
        //...
      }
      if (foo == bar)
      {
        //..
      }
    };
    
  1. Always use var when declaring variables, unless you really do mean to create a global variable.
Last modified 8 years ago Last modified on 11/18/08 10:05:21