Changeset 6198 for trunk/documents

Show
Ignore:
Timestamp:
10/16/06 15:41:49 (2 years ago)
Author:
skinner
Message:

Fixed a few dozen glitches on the JavaScript? Programming Conventions web page -- typos, misspellings, grammatical problems.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/documents/articles/js_style_guide.rest

    r3068 r6198  
    3131package        lower                      never multiple words 
    3232class          UpperLower 
    33 public method  lowerUpper                 whether class or instance method. lower_case() is acceptable only if the particular function is mimicing another API. 
     33public method  lowerUpper                 whether class or instance method. lower_case() is acceptable only if the particular function is mimicking another API. 
    3434public var     lowerUpper 
    3535constant       UpperLower or UPPER_LOWER 
     
    7575        obj.getSomeValue() 
    7676 
    77 F.  Public class variables MUST be written using upperLower case. 
    78 G.  Private class variables MAY be written using ``_upperLower`` (with 
     77F.  Public class variables MUST be written using lowerUpper case. 
     78G.  Private class variables MAY be written using ``_lowerUpper`` (with 
    7979    preceding underscore):: 
    8080 
     
    8585        } 
    8686 
    87 H.  Variables that are intended to be private, but cannot be based on the 
    88     semantics of Javascript, SHOULD prepended with a "_" (underscore) char:: 
    89  
    90         this._somePrivateVariable = statement ; 
    91  
    92     NB  Note that the above variable also follows the convention for a 
     87H.  Variables that are intended to be private, but cannot be, based on the 
     88    semantics of Javascript, SHOULD be prepended with a "_" (underscore) char:: 
     89 
     90        this._somePrivateVariable = statement; 
     91 
     92    Note that the above variable also follows the convention for a 
    9393    private variable. 
    9494 
    9595I.  Generic variables SHOULD have the same name as their type:: 
    9696 
    97         setTopic(topic) //  where topic isTypeOf Topic 
     97        setTopic(topic) //  where topic is of type Topic 
    9898 
    9999J.  All names SHOULD be written in English. 
    100 K.  Variables with a large scope SHOULD have globally unambiguious names, 
    101     ambiguity MAY be distinguished by package memebership. Variables with 
     100K.  Variables with a large scope SHOULD have globally unambiguious names; 
     101    ambiguity MAY be distinguished by package membership. Variables with 
    102102    small or private scope MAY be more terse still. 
    103103L.  The name of the return object is implicit, and SHOULD be avoided in a 
     
    129129        MouseEventHandler 
    130130 
    131     NB  The base class CAN be dropped from a name if it is obviously 
     131    The base class CAN be dropped from a name if it is obviously 
    132132    implicit in the name:: 
    133133 
    134134        MouseEventHandler as opposed to MouseUIEventHandler. 
    135135 
    136 Specific Naming conventions 
     136Specific Naming Conventions 
    137137*************************** 
    138138 
    139139A.  The terms get/set SHOULD NOT used where a field is accessed, unless the 
    140140    variable being accessed is lexically private. 
    141 B.  "is" prefix SHOULD be used for boolean variables and methods 
    142     NB. Alternatives include "has", "can" and "should" 
     141B.  The "is" prefix SHOULD be used for boolean variables and methods. 
     142    Alternatives include "has", "can" and "should". 
    143143C.  The term "compute" CAN be used in methods where something is computed. 
    144144D.  The term "find" CAN be used in methods where something is looked up. 
     
    146146    concept is established. 
    147147F.  UI Control variables SHOULD be suffixed by the control type. 
    148     ex.  leftComboBox, topScrollPane 
     148    Examples:  leftComboBox, topScrollPane 
    149149G.  Plural form MUST be used to name collections. 
    150 H.  "num" prefix or "count" postfix SHOULD be used for variables 
     150H.  The "num" prefix or "count" postfix SHOULD be used for variables 
    151151    representing a number of objects. 
    152152I.  Iterator variables SHOULD be called "i", "j", "k", etc. 
    153 J.  Compliment names MUST be used for compliment entities. 
    154     ex.  get/set, add/remove, create/destroy, start/stop, insert/delete, 
     153J.  Complement names MUST be used for complement entities. 
     154    Examples:  get/set, add/remove, create/destroy, start/stop, insert/delete, 
    155155    begin/end, etc. 
    156156K.  Abbreviations in names SHOULD be avoided. 
     
    169169B.  Tabs (set to 4 spaces) SHOULD be used for indentation.  
    170170C.  If your editor supports "file tags", please append the appropriate tag 
    171     at the end of the file enable others to effortlessly obey the correct 
     171    at the end of the file to enable others to effortlessly obey the correct 
    172172    indentation guidelines for that file:: 
    173173 
    174174        // vim:ts=4:noet:tw=0: 
    175175 
    176 C.  The incompleteness of split line MUST be made obvious:: 
     176C.  The incompleteness of a split line MUST be made obvious:: 
    177177 
    178178        var someExpression = Expression1 
    179179            + Expression2 
    180             + Expression3 ; 
     180            + Expression3; 
    181181 
    182182        var o = someObject.get( 
     
    206206E.  Loops / iterative declarations 
    207207 
    208     1.  Only loop control statements MUST be included in the "for()" 
     208    1.  Only loop control statements MUST be included in the "for" loop 
    209209        construction. 
    210210    2.  Loop variables SHOULD be initialized immediately before the loop; 
    211211        loop variables in a "for" statement MAY be initialized in the "for" 
    212212        loop construction. 
    213     3.  The use of "do...while" loops are acceptable (unlike in Java) 
    214     4.  The use of "break" and "continue" is not discouraged (unlike in Java) 
     213    3.  The use of "do...while" loops is acceptable (unlike in Java). 
     214    4.  The use of "break" and "continue" is not discouraged (unlike in Java). 
    215215 
    216216F.  Conditionals 
     
    235235 
    236236A.  Block statements. 
     237 
    237238    1.  Block layout SHOULD BE as illustrated below:: 
    238239 
     
    242243            } 
    243244 
    244     2.  If statements SHOULD have the following form:: 
     245    2.  An "if" statement SHOULD have the following form:: 
    245246 
    246247            if(someCondition){ 
     
    252253            } 
    253254 
    254     3.  for statements SHOULD have the following form:: 
     255    3.  A "for" statement SHOULD have the following form:: 
    255256 
    256257            for(initialization; condition; update){ 
     
    258259            } 
    259260 
    260     ..  FIXME: (alex) this reference should use reST reference syntax! 
    261  
    262     4.  while statement SHOULD follow the form in example VI.A.1. 
    263     5.  a do...while statement SHOULD have the following form:: 
     261    4.  A "while" statement SHOULD have the following form:: 
     262         
     263            while(!isDone){ 
     264                statements; 
     265                isDone = moreToDo(); 
     266            } 
     267 
     268    5.  A "do...while" statement SHOULD have the following form:: 
    264269 
    265270            do{ 
     
    267272            }while (condition); 
    268273 
    269     6.  a switch statement SHOULD have the following form:: 
     274    6.  A "switch" statement SHOULD have the following form:: 
    270275 
    271276            switch (condition){ 
     
    281286            } 
    282287 
    283     7.  A try...catch...finally statement SHOULD have the following form:: 
     288    7.  A "try...catch...finally" statement SHOULD have the following form:: 
    284289 
    285290            try{ 
     
    291296            } 
    292297 
    293     8.  Single statement if-else, while or for MUST NOT be written without 
     298    8.  A single statement if-else, while or for MUST NOT be written without 
    294299        brackets, but CAN be written on the same line:: 
    295300 
     
    307312    5.  Semi-colons in for statements SHOULD be followed by a space. 
    308313    6.  Semi-colons SHOULD NOT be preceded by a space. 
    309     7.  Functions/method calls SHOULD NOT be followed by a space. 
    310         ex. doSomething(someParameter);     //  NOT doSomething (someParameter) 
     314    7.  Functions/method calls SHOULD NOT be followed by a space: 
     315         
     316        doSomething(someParameter);     //  NOT doSomething (someParameter) 
     317                 
    311318    8.  Logical units within a block SHOULD be separated by one blank line. 
    312319    9.  Statements MAY be aligned wherever this enhances readability.