~testplan-team/testplan/source-collection

« back to all changes in this revision

Viewing changes to selenium-core-1.0.1/coding-conventions.txt

  • Committer: edA-qa mort-ora-y
  • Date: 2009-07-02 09:23:56 UTC
  • Revision ID: eda-qa@disemia.com-20090702092356-w9rxifuvlva3bk31
upgradingĀ selenium

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
            Coding standards for Selenium Core Javascript code
 
2
            --------------------------------------------------
 
3
 
 
4
  Here is a set of conventions agreed by the active Selenium Core
 
5
  developers at ThoughtWorks.  Please stick to these guidelines when
 
6
  working on the Selenium Core code-base.
 
7
 
 
8
Whitespace: we use spaces, NOT TABS.  Indent in 4-space increments.
 
9
 
 
10
Braces: we place open-braces on the same line as the associated keyword,
 
11
  for example:
 
12
 
 
13
        if (command.isBreakpoint) {
 
14
            this.pause();
 
15
        } else {
 
16
            window.setTimeout(this.resume.bind(this), delay);
 
17
        }
 
18
 
 
19
Encapsulation: we prefer to encapsulate functions and variables inside
 
20
  objects, where possible.
 
21
 
 
22
Variable declarations: declare variables (using "var") ... even if they're
 
23
  "global".
 
24
 
 
25
Class definitions: we're shifting to "prototype.js" style for
 
26
  definition of classes, e.g.
 
27
 
 
28
        var MyClass = Class.create();
 
29
        Object.extend(MyClass.prototype, {
 
30
        
 
31
            initialize: function() {
 
32
                // ... constructor code ...
 
33
            },
 
34
        
 
35
            doStuff: function() {
 
36
                // ... method body ...
 
37
            }
 
38
        
 
39
        });
 
40
 
 
41
'Private' functions/properties: we simulate "private" properties by
 
42
  prepended the name with an underscore ("_"), e.g.
 
43
 
 
44
        _resumeAfterDelay : function() {
 
45
            // ...etc...
 
46
        },
 
47
 
 
48
Element addressing: use "$(id)" rather than
 
49
  "document.getElementById('id')".
 
50
 
 
51
Timeout functions: pass function objects to setTimeout(), rather than
 
52
  strings, e.g.
 
53
 
 
54
        window.setTimeout(this.resume.bind(this), delay);